title: When reflecting: Should set property or directly set value? (Objective-C)
body: <p>I'm writing an xml serialization class for objective-c.<br/>
  The point is to give the class a class type and an xml file.
  It should return an instance with data.</p>
  
  <p>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.<br/>
  Obviously this relies heavily on reflection.</p>
  
  <p>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?</p>
  
  <p>This is the kind of code I've used so far:</p>
  
  <pre><code>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"]);
  </code></pre>
  
  <p>Also, after this kind of assignment, should I release anything?</p>