Tiago Scolari

bits for fun

Asynchronous UISearchBar / UISearchDisplayController With Autocomplete

2011-08-19 Code

This is my second week working with objective-c and iphone. The task is to make a search with autocomplete. Both search and autocomplete should get results from a remote webservice. I was searching google about how to populate a UISearchDisplayController with remote data, asynchronously of course, when I found a great guide here.

I already had a working datasource for autocomplete:

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
    [_autocompleteDataSource searchFor:searchString];
    return NO;
}

The trick was to reload the tableview data in my datasource ([tableView reloadData]), when it finishes loading.

Continue reading