Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use NSFetchedResultsControllerDelegate to update TableView sections & rows after NSPredicate change

Is there a way to update a UITableView sections and rows after changing the fetchedResultsControllers NSpredicate (and executing the fetch)? I would like to use controllerWillChangeContent delegate methods to update my table when the searchText in my searchBar is changed.

Currently in my app, these delegate methods only get called when changes in coredata occur. Not when changing the resultsController predicate & executing the fetch.

If I simply call [self.tableView reloadData] on each textchange, there are no animations and it blocks the experience a bit.

Or should I do something completely different to update the tableView contents on each search text entry change?

like image 428
Tycho Pandelaar Avatar asked Jan 01 '11 14:01

Tycho Pandelaar


1 Answers

I've had another look into Apple's documentation and it looks like the NSFetchedResultsControllerDelegate methods are not called when a predicate has changed:

An instance of NSFetchedResultsController uses methods in this protocol to notify its delegate that the controller’s fetch results have been changed due to an add, remove, move, or update operations.

So, to answer my own question: It's not possible to use NSFetchedResultsControllerDelegate to update the table after NSFetchedResultsController predicate changes.

like image 121
Tycho Pandelaar Avatar answered Nov 05 '22 01:11

Tycho Pandelaar