I use NSFetchedResultsController to populate and manage the data source of my tables.
When the user selects a specific row, an action sheet appears, and then the user can change the value for that row:
NSManagedObject *managedObject = [fetchedResultsController objectAtIndexPath:selectedRowIndexPath]; [managedObject setValue:status forKey:@"status"];
This works very well, and I can immediately see the changes in the table view. This means that NSFetchedResultsController knows that something has changed and therefore reloads this table. When I stop and leave the application (completely), and then open it again, the change is not saved.
I think NSFetchedResultsConroller will take care of saving the changes.
Do I need to save manually using the following code after each change?
// Save the context. NSError *error = nil; if (![self.managedObjectContext save:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); }
Or maybe name this code in:
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath
source share