Core Data and Key-Value Coding

Discussion in 'Mac Programming' started by gormster, Jan 31, 2010.

  1. gormster macrumors newbie

    Joined:
    Jan 21, 2010
    #1
    Hi guys

    I've got a bit of a weird problem. I've got a one-to-one relationship between two entities in my Core Data model, called Trigger and View. (Before you jump on that, I've already tried renaming it, it's not a reserved word issue.)

    Here's the extremely odd thing - I can't seem to traverse this relationship through KVC. Here's some code

    Code:
    //this works
    NSManagedObject* view = [trigger valueForKey:@"view"];
    int locx = [[view valueForKey:@"locX"] intValue];
    
    //this doesn't
    int locx = [[trigger valueForKey:@"view.locX"] intValue];
    
    WTF. Both objects were instantiated with the insertNewObjectForEntityForName:inManagedObjectContext: method of NSEntityDescription, and the view was assigned to the trigger by was of setValue:forKey:. The error I get is 'the entity Loop is not key value coding-compliant for the key "view.locX".'
     
  2. JoshDC macrumors regular

    Joined:
    Apr 8, 2009
  3. gormster thread starter macrumors newbie

    Joined:
    Jan 21, 2010
    #3
    Hello, world. My name is gormster. I am an idiot who was using the wrong method name.




    Thanks, JoshDC.
     

Share This Page