title: Using setValuesForKeysWithDictionary with child objects and JSON
body: <p>I have a json string</p>
  
  <pre><code>{"name":"test","bar":{"name":"testBar"}}
  </code></pre>
  
  <p>In objective c I have an object</p>
  
  <pre><code>@interface Foo : NSObject {
  }
  @property (nonatomic, retain) NSString * name;
  @property (nonatomic, retain) Bar * bar;
  @end
  </code></pre>
  
  <p>And I just synthesize those properties.  And I have a child object with synthesized properties.</p>
  
  <pre><code>@interface Bar : NSObject {
  }
  @property (nonatomic, retain) NSString * name;
  @end
  </code></pre>
  
  <p>Then here is the code where I'm trying to get into the Foo object where response is the json string above:</p>
  
  <pre><code>    SBJsonParser *json = [[SBJsonParser new] autorelease];
      parsedResponse = [json objectWithString:response error:&amp;error];
      Foo * obj = [[Foo new] autorelease];
      [obj setValuesForKeysWithDictionary:parsedResponse];
      NSLog(@"bar name %@", obj.bar.name);
  </code></pre>
  
  <p>This throws an exception on the NSLog statement of:</p>
  
  <pre><code>-[__NSCFDictionary name]: unrecognized selector sent to instance 0x692ed70'
  </code></pre>
  
  <p>But if I change the code to it works:</p>
  
  <pre><code>NSLog(@"bar name %@", [obj.bar valueForKey:@"name"]);
  </code></pre>
  
  <p>I'm confused at why I can't do the first example, or am I doing something wrong?</p>