theprole
theprole

Reputation: 2344

Modifying managed objects obtained from NSFetchedResultsController

I have a simply core data model which has two entities, a Person and a Photo. Person has a one-to-many relationship with Photos. Everything works fine, and when I access the photoList property on Person I get an NSSet with all the photos for that person.

My question is, how can I modify the managed objects in that set and the commit the results back to the core data backstore? At the moment, if I modify one of the Photo managed objects in the set they don't get saved.

The code looks something like this:

Person *myPerson = [fetchedResultsController objectAtIndexPath:indexPath];

[photosController setPhotos:[[myPerson photoList] allObjects]];

Where the set that the photosController gets is perfectly readable, but modifying its content does not update the backend store.

Thanks for all the help

Upvotes: 0

Views: 112

Answers (1)

Justin Spahr-Summers
Justin Spahr-Summers

Reputation: 16973

Changes to managed objects are only retained in memory until you save the managed object context of the objects. Once that's done, the changes will be committed to the persistent store.

Upvotes: 1

Related Questions