开发者

disposing of an NSManagedObject that was not saved

开发者 https://www.devze.com 2023-03-05 21:55 出处:网络
I created an (overriding) instance of NSManagedObject, using insertNewO开发者_如何学PythonbjectForEntityForName:.

I created an (overriding) instance of NSManagedObject, using insertNewO开发者_如何学PythonbjectForEntityForName:.

If I never saved the context (and did not increase its retain count), do I still need to delete it using obj.managedObjectContext deleteObject:obj ?

If so, and assuming it's retained, do I first delete it and then release it?


Once you use insertNewObjectForEntityForName: the object will be within your NSManagedObjectContext regardless of whether you retain the NSManagedObject product of the insert call. Its irrelevant to this question whether you have retained the context.

You can always get an instance of that entry by querying the context in an appropriate manner. It might be the original NSManagedObject instance that insert gave you or it might not. Depends on the workings of your app.

If you want that object out of there again you need to delete it from the context or revert back to the most recent saved state somehow.

0

精彩评论

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