NSTokenField Offer, but not complete

It seems to me that this should be a common problem, which I'm just trying to understand, but I could not find anyone else who asked the question like this ... Basically, I have an NSTokenField, and when the user starts typing, I do SOAP- request and I get names similar to what they entered. The problem is that my suggestions do not necessarily correspond to what they typed. For example, I match email addresses and last names, but the full name of the person appears in the array of sentences. Since the letters do not match, the NSTokenField changes what has already been entered into the first element of the array. Is there a way to turn off autocomplete and just a window with a suggestion will appear?

+5
source share
2 answers
    - (NSArray *)tokenField:(NSTokenField *)tokenField completionsForSubstring:(NSString *)substring indexOfToken:(NSInteger)tokenIndex indexOfSelectedItem:(NSInteger *)selectedIndex
{
    *selectedIndex = -1;
    return NSArray;
}

It turns out that I incorrectly assigned selectIndex, but if you just set it to -1, then nothing will be selected.

+8
source

In the quick answer:

if selectedIndex != nil {
    selectedIndex.memory = -1
}
0
source

All Articles