开发者

Updating an Item in Core Data

开发者 https://www.devze.com 2023-01-16 19:54 出处:网络
I am new to Core Data. I fetch few objects into an NSMutableArray. Now I want to update an object with objectID x.

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.
   }
0

精彩评论

暂无评论...
验证码 换一张
取 消