REAutoComplete
UITextField category to add autocomplete suggestions in a UITableView.
Usage
Adapt REAutoCompleteItem protocol:
#import <REAutoComplete/REAutoComplete.h>
@interface NSString (REAutoCompleteItem) <REAutoCompleteItem>
@end
@implementation NSString (REAutoCompleteItem)
- (NSString*)autoCompleteText {
return self;
}
@end
DataSource based:
#import <REAutoComplete/REAutoComplete.h>
- (void)viewDidLoad {
[super viewDidLoad];
self.textField.autoComplete.dataSource = self;
self.textField.autoComplete.delegate = self;
}
#pragma mark <REAutoCompleteDataSource>
- (void)autoComplete:(REAutoComplete*)autoComplete suggestionsFor:(NSString*)query whenReady:(void (^)(NSArray<id<REAutoCompleteItem>>* suggestions))callback {
callback(@[@"suggestion"]);
}
Algorithm based:
#import <REAutoComplete/REAutoComplete.h>
- (void)viewDidLoad {
[super viewDidLoad];
id<REAutoCompleteAlgorithm> algorithm = <algorithm>;
self.textField.autoComplete.algorithm = algorithm;
self.textField.autoComplete.delegate = self;
}
Installation
REAutoComplete is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'REAutoComplete'
Author
Rinat Enikeev, http://rinat-enikeev.github.io
License
REAutoComplete is available under the MIT license. See the LICENSE file for more info.