So I noticed some strange behavior when using a subclass of a NSManagedObject as a property of one of my controllers. I understand that instances of these classes are managed by core data and should not be treated as normal objects with respect to their lifetimes.
My question is what is the best practice if you have a core data object as a property of another (non-core data) class?
I found that in order to get the behavior I wanted I had to retain the core data object when fetched or created, then set the property like so:
@property (nonatomic, assign) MBUser* userProfile;
Is this the best practice or is there some other way to accomplish what I want?
I believe that if a managed object has a retain count of 0, then the system will deallocate, therefore you must retain your object to ensure it is not deallocated by the core data system…I haven’t found this written like this in txt but I believe the core data guide here implies it Link