Reputation: 1567
I'm coding iOS 6.1 and learning Core Data.
If I have a Core Data entity/object in memory and I write it out, can I continue to hold a copy in memory, update it and write it out again?
Or, once I've written it out, do I have to read it in again to update it and then write it out again?
Upvotes: 0
Views: 390
Reputation: 2784
As you probably know already, Core Data uses both a persistent store and a managed object context. Data is loaded and saved using the managed object context.
The answer to your first question is yes. As long as your local reference variable is still in scope, you are able to update/save the content of the variable as many times as you want; remember, though, that it won't save to your back end unless you explicitly save your managed object context: [NSManagedObjectContext save:(NSError*)error]
.
Once that reference variable has gone out of scope, you'll need to fetch the managed object again if you want to edit it in any way.
Upvotes: 1