I am doing an automatic mapping from XML to NSObject while parsing if the XML nodes names match the NSObject instance variable names. It’s done through obj-c runtime easily with (elementName is a XML child node name):
void* ivarValue = nil;
Ivar ivar = object_getInstanceVariable(self, [elementName cStringUsingEncoding:NSUTF8StringEncoding], &ivarValue); // Get the iVar with name 'elementName' from current instance
I tried to do the same with NSManagedObject with no success. Is possible to use objc/runtime.h with Core Data? If not, is there an alternative to retrieve the instance variables or its type (assuming you know its names)?
Thanks!
Check the NSManagedObject entity description for the relevant properties and use KVC for setting values