I'm writing an xml serialization class for objective-c.
The point is to give the class a class type and an xml file.
It should return an instance with data.
I've got it working, and it does quite a bit - handles primitives (+nsstring), user defined classes and nsarrays. Doesn't handle pointers or C-arrays.
Obviously this relies heavily on reflection.
The question: When I set a value of an instance of some class, should I be checking if a property with the right name exists, or can I just set the variable using simple reflection?
This is the kind of code I've used so far:
id newClass = class_createInstance(NSClassFromString(elementName), sizeof(unsigned));
Ivar nameVar = class_getInstanceVariable([newClass class], "name");
if (nameVar != nil)
object_setIvar(newClass, nameVar, [NSString stringWithString:@"George"]);
Also, after this kind of assignment, should I release anything?