I’m trying to implement a better live(search as you type) contact search in my iPhone app. After doing some real device testing if found my current (non-threaded) implementation is just too slow. As far as I know there is no spotlight API for the iPhone. So I think the solution will have to be threaded so that it updates the results every x seconds instead of every keystroke. Are there any open source implementations I could build upon?
Thanks!
As far as I know there is no spotlight API for the iPhone.
You don’t need one. Here’s one way to go about it:
NSFetchedResultsControllerto manage a result setUISearchDisplayControllerto apply anNSPredicateon the result set in real timeThe only threading I can see that you would need is a separate thread to populate the Core Data store with contacts.
Once you have a result set via
NSFetchedResultsController, it is quite easy to apply a predicate. For example:will filter the result set
[self.fetchedResultsController fetchedObjects]on the fly.