NSTokenField value binding returns array rather than string

Originator:amorya
Number:rdar://11226270 Date Originated:11-Apr-2012 11:27 AM
Status:Open Resolved:
Product:MacOS X SDK Product Version:10.7
Classification:Other bug Reproducible:Always
 
11-Apr-2012 11:27 AM Amy Worrall:
Summary:
The documentation says that the value binding for an NSTokenField should supply an NSString or an NSNumber. However, if I bind the NSTokenField to something expecting a string, I get a crash since the NSTokenField supplies an array.

Steps to Reproduce:
1. Create an NSTokenField in the UI editor of Xcode
2. Create a controller with an NSString property
3. Bind the token field's "value" binding to the controller's string property
4a. Try setting the controller's string property in code to a string containing a comma separated list
4b. Enter text in the token field including some commas, to make it produce tokens, then commit the editing

Expected Results:
4a. The comma separated list appears in the token field as separate tokens
4b. The separate tokens are concatenated to form a comma separated list, which is assigned to the string property

Actual Results:
4a. Works as expected
4b. I get a problem along the lines of the following:

Unacceptable type of value for attribute: property = "OccasionTags"; desired type = NSString; given type = __NSArrayI; value = (
    Elevenses,
    "Afternoon tea"
).

Notes:
The token field, when changed by the user, passes an NSArray through its value binding. This contradicts the documentation, which states that the value binding is "An NSString or NSNumber that is displayed as the content of the NSTokenField". 

I suggest that NSTokenField be given an additional binding, valueArray, which should supply and take an array (i.e. the current behaviour of the value binding). Then, the value binding be amended so that it actually both supplies and consumes an NSString.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!