I'm developing an app for MacOS X in Xcode5
I want to autocomplete option typed on textfield when user types or deletes text, for instance if user types "Me" then Mexico option is displayed on list of options, so far this is my code:
@interface ComboNSObject()<NSComboBoxCellDataSource, NSComboBoxDataSource, NSComboBoxDelegate>{
NSArray *datos;
}
@property (weak) IBOutlet NSComboBox *myCombo;
@end
@implementation ComboNSObject
-(void)awakeFromNib{
datos = [[NSArray alloc]initWithObjects:@"Mexico",@"Guatemala",@"USA",@"Chile",@"Argentina", nil];
[_myCombo addItemsWithObjectValues:datos];
}
- (NSString *)comboBox:(NSComboBox *)comboBox completedString:(NSString *)partialString
{
for (NSString *dataString in datos) {
NSLog(@"encontrado: %@", [dataString commonPrefixWithString:partialString options:NSCaseInsensitiveSearch]);
}
return @"";
}
@end
I already set delegate and datasource of _myCombo and also of its NSComboBoxCell on my NSObjectController but nothing happens, what's the proper code for showing my autocompletion