开发者

Help with a Core Data Concept

开发者 https://www.devze.com 2023-03-13 04:12 出处:网络
Just want to confirm that I have this correct, and would like to see some sample code. When I want to add a new record to Core Data, I create a new instance of an NSManagedObject subclass, correct? T

Just want to confirm that I have this correct, and would like to see some sample code.

When I want to add a new record to Core Data, I create a new instance of an NSManagedObject subclass, correct? Then what? (Some sample 开发者_StackOverflowcode would be welcome.)


Assuming moc is your managed object context and obj is your newly created managed object,

[moc insertObject:obj];

// save to persistent store
NSError *error;
if (![moc save:&error]) {
    // handle error
}
0

上一篇:

:下一篇

精彩评论

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