私自身の解決策は実際には非常に単純でした。オートコンプリートの候補のリストに検索文字列自体を追加するだけです。
これはNSSearchField
デリゲートメソッドで行われcontrol:textView:completions:forPartialWordRange:indexOfSelectedItem:
ます:
...
partialString = [[textView string] substringWithRange:charRange];
...
matches = [NSMutableArray array];
// find any match in our keyword array against what was typed -
for (i=0; i< count; i++)
{
string = [keywords objectAtIndex:i];
if ([string
rangeOfString:partialString
options: NSCaseInsensitiveSearch | NSForcedOrderingSearch
range:NSMakeRange (0, [string length])]
.location != NSNotFound) {
[matches addObject:string];
}
}
[matches sortUsingSelector:@selector(compare:)];
// Make sure we insert the already entered string, even if it does not
// match with any of the retrieved keywords. This will enter this string
// in the search field, as we intended, and it will not be overwritten
// with any match.
[matches insertObject:partialString atIndex: 0];
return matches;