开发者

core data simple update?

I'm a beginner on core data and try to understand how to simply update an ob开发者_Go百科ject which is already stored.

myObject is a NsManagedObject

setValue forKey needs .. a key but how could I update with something like setValue:mynewvalue forkey:myObject.key

ok that's not the way.


First, if you can, create your own custom NSManagedObject subclasses with mogenerator. It'll save you a lot of time getting data in and out of Core Data.

If you have to go with the generic NSManagedObject route, try this:

id objectKey = @"key";
id valueToStore = @"Save this";

NSManagedObject *myObj = ...;
[myObj setValue:valueToStore forKey:objectKey];

and to update it, try:

[myObj setValue:@"my new value" forKey:objectKey];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜