As-You-Type-Search with Master Data / NSFetchedResultsController
I have implemented a search by type (text search on one attribute) by selecting with performFetch:
after each given character by the user. performFetch:
runs on a background thread to avoid keyboard hangs.
But when typing many unnecessary notes, it starts. Perhaps NSOperationQueue might be an option, but I'm wondering if there are other approaches for this common behavior.
What's the best thing to notice when a selection is made and the table view is updated with the previous selection to start a new selection?
a source to share
You don't need to pop into the master data stack after every letter. Instead, you can run NSPredicate against fetchedObjects
those already in the instance NSFetchedResultsController
. This saves you the hassle of making selections on a background thread, because you are simply filtering out results that are already in memory and it will fix the performance issue.
As you enter each letter, you customize NSPredcate
and the results are filtered further.
a source to share