NSTokenField Represented Objects
NSTokenField Represented Objects
- Subject: NSTokenField Represented Objects
- From: Jason Wiggins <email@hidden>
- Date: Wed, 12 Nov 2008 04:02:14 +1100
Hello all,
I'm having a bit of trouble with NSTokenFields and represented objects.
What I am trying to achieve is to create a predicate from text entered
in a token field. It goes like this:
User enters text, gets a completion if necessary, types tokenising
character, token created, user presses a start button, the token's
represented object returns a uti for inclusion in the predicate.
The token field has completions for substring method implemented in
its delegate as such:
- (NSArray *)tokenField:(NSTokenField *)tokenField
completionsForSubstring:(NSString *)substring indexOfToken:
(NSInteger)tokenIndex indexOfSelectedItem:(NSInteger *)selectedIndex {
...
else if (tokenField == fileTypeTokenField) {
NSArray *matchingFileTypes = [[fileTypeArray
valueForKey:@"description"] filteredArrayUsingPredicate:[NSPredicate
predicateWithFormat:@"SELF beginswith[cd] %@", substring]];
return matchingFileTypes;
...
fileTypeArray is an array of dictionaries comprising a description key
and a UTI key.
All is good for the user entering some text in the token field and
getting matches for the substring. The user types the tokenising
character and the token is created. But now it seems there is no
connection to the dictionary object. The class of the represented
object is now NSCFString not NSDictionary.
I also have this delegate method implemented:
- (NSString *)tokenField:(NSTokenField *)tokenField
displayStringForRepresentedObject:(id)representedObject {
if (tokenField == fileTypeTokenField) {
return representedObject;
}
}
Do I have to implement tokenField:representedObjectForEditingString: ?
If so how?
Any ideas or thoughts would be greatly appreciated.
Regards,
Jason
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden