i have an NSManagedObject that has just attributes(no fetched properties or relationshiops). I retain the instance, tell the managed context to remove the object from the graph, i persist the managed context.
is it safe to use the instance after the removal from the managed context?
Step by step:
->retain NSManagedObject
->remove NSManagedObject from managed object context
->persist changes to the managed object context
->use NSManagedObject
I don’t believe so. A NSManagedObject belongs to the store. You use the store to create and destroy it. Be very cautious if you decide to do otherwise because as the NSManagedObject docs say, “it is important to remember that Core Data reserves exclusive control over the life cycle of the managed object (that is, raw memory management).”
Doesn’t this imply that the object is released anyway? Certainly you can ignore it from then on without leaking.
Because you have a simple object with only attributes just copy them if you need to keep them around.