Is there a way to cast an NSManagedObject to a sub-classed object?
I have @interface Contact : NSManagedObject and in a generic part of my code I have an NSManagedObject, I would like to cast it to Contact to be able to access properties directly using contact.firstName etc…
I am using Contact *contact = myManagedObject; which works at run time but I am getting the compiler warning warning: incompatible Objective-C types initializing 'struct NSManagedObject *', expected 'struct Contact *' that I would like to suppress.
Use a C cast:
Be aware that this is quite a bit of rope. Sometimes necessary rope, certainly.