Updating an Item in Core Data
I am new to Core Data. I fetch few objects into an NSMutableArray. Now I want to update an object with objectID x.
My question is: How do I get the objectId for an object? and then how do I perform updates on that par开发者_开发百科ticular object? (eg: change 'Name' attribute and save)
Thanks
You get the ID by calling [myObject objectID]
. You can update and save a new value by calling your objects accessors like you would with any other object. Then to write the changes to the persistent store you do:
NSError *error;
if (![managedObjectContext save:&error]) {
// Handle the error.
}
精彩评论