iPhones SDK: Setting a relationship property object using core data?

Posted by Harkonian on Stack Overflow See other posts from Stack Overflow or by Harkonian
Published on 2010-03-13T02:18:18Z Indexed on 2010/03/13 2:27 UTC
Read the original article Hit count: 366

I'm using core data in my app. I have two entities that are related: EntityA and EntityB. EntityA has a property of type "relationship" with EntityB. In addition, both of these entities are defined classes (not the default NSManagedObject). I'm inserting a new object into my data like this:

EntityA *newEntityA = [NSEntityDescription insertNewObjectForEntityForName:@"EntityA" inManagedObjectContext:self.managedObjectContext];

newEntityA.name = @"some name";
newEntityA.entityB.name = @"some other name";

The problem is entityB.name is null. Even if I add an NSLog() statement right after assigning the value, it is null. What is the proper way of setting my "name" property of EntityB when EntityB is a property of EntityA?

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about core-data