views:

113

answers:

1

I implemented an as-you-type-searching (text search on single attribute) by fetching with performFetch: after each given character by the user. The performFetch: is running in a background thread to avoid keyboard freezes.

But while typing many useless fetches are started. A NSOperationQueue might be an option, but I wonder if there are other approaches for this quite usual search behavior.

What's best practice to notice when fetching is done and the table view is updated with the previous fetch to start a new fetch?

+1  A: 

You don't need to perform a fetch on the Core Data stack after each letter. You can instead run a NSPredicate against the fetchedObjects that are already in the NSFetchedResultsController instance. This will remove the need to perform fetches on a background thread because you are simply filtering against the results that are already in memory and it will remove the performance issue.

As each letter is typed you adjust the NSPredcate and the results are filtered further.

Marcus S. Zarra
Thanks, I'll try the approach running a NSPredicate on `fetchedObjects`.
Sney