mhbdr
mhbdr

Reputation: 753

Refresh entire NSFetchedResultsController tableView

I'm using refreshObject:mergeChanges: to refresh a single cell in my Core Data tableView by getting the indexPath for that cell. Is it possible to refresh the entire tableView instead of that single cell? I've only found that refreshObject:mergeChanges: works for what I need to do.

Upvotes: 0

Views: 844

Answers (1)

Jody Hagins
Jody Hagins

Reputation: 28389

Just refetch your data.

There is a property, setShouldRefreshRefetchedObjects that ensures fetch requests go down to the store.

setShouldRefreshRefetchedObjects: Sets whether the fetch request should cause property values of fetched objects to be updated with the current values in the persistent store.

- (void)setShouldRefreshRefetchedObjects:(BOOL)flag

Parameters

flag YES if the fetch request should cause property values of fetched objects to be updated with the current values in the persistent store, otherwise NO

Discussion

By default, when you fetch objects they maintain their current property values, even if the values in the persistent store have changed. By invoking this method with the parameter YES, when the fetch is executed the property values of fetched objects to be updated with the current values in the persistent store. This provides more convenient way to ensure managed object property values are consistent with the store than by using refreshObject:mergeChanges: (NSManagedObjetContext) for multiple objects in turn.

Upvotes: 2

Related Questions