NSTokenField completion problems
NSTokenField completion problems
- Subject: NSTokenField completion problems
- From: Danny Hall <email@hidden>
- Date: Fri, 8 Jun 2007 19:55:59 -0400
Greetings
I am using NSTokenField the same way that Mail.app does. I'm linking
against the AddressBook frameworks and implementing the NSTokenField
delegate method
tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem:.
I retrieve matches from AB for the substring entered by the user and
format the matches into an array of possible patterns: (first, last,
email) or (email, first, last), etc. Then I compare these items
against the value of the token field that I am passed using
[tokenField stringValue], to make sure I only return strings that
begin with what is already in the token field.
This works fine for the first token, but every subsequent token
refuses to match valid the current token field string value to the
array of items retrieved from the AddressBook database.
The run log shows the address records are retrieved and formatted,
and the string I am trying to match, but for whatever reasons valid
matches won’t match no matter what method I try.
First token:
===== MATCHED ====== "Fred Smith <xxxxxxxxx>" does contain "Fred"
Second token:
===== No match ====== "Fred Smith <xxxxxxxxx>" does NOT contain "Fred"
I’ve tried
commonPrefixWithString:options:
compare:options:range:
rangeOfString:
As well as, copying the strings first, transforming to c strings,
then back again, and making new strings with “stringWithFormat”.
If insert a dummy line
Return [NSArray arrayWithObjects:@”1”, @”2”, @’3”, niil];
At the beginning of the delegate method, it works great for every
token, so I know the problem is something is screwey about the string
passed to me from the token field.
I’m stuck. Has anyone seen behavior like this, or can someone offer
pointers?
Thanks
Danny_______________________________________________
Cocoa-dev mailing list (email@hidden)
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