开发者

What is the simplest way to know that NSManagedObject instance is new and hasn't been persisted yet?

I've found isInserted property, but开发者_StackOverflow中文版 what if I created object without inserting it into managed context? Maybe I can use ObjectID somehow for such a purpose?


Is inserted should work fine, because you cannot create a managed object without inserting it. You could also use the isTemporaryID method on the objectID, which returns YES if the object was not yet inserted.

Keep in mind that inserted does not mean persisted. If you insert an object into a managed object context you must first save the context before the object will be persisted (and then in turn the object does not count as being inserted anymore).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜