Using iPhone Core Data to many Relationship
Posted
by BLeB
on Stack Overflow
See other posts from Stack Overflow
or by BLeB
Published on 2010-06-01T18:26:12Z
Indexed on
2010/06/01
19:14 UTC
Read the original article
Hit count: 162
When I define a to many relationship between entities in Xcode and then generate the data class from the entity I get a header with the following methods defined:
@interface PriceList (CoreDataGeneratedAccessors)
- (void)addItemsObject:(PriceListItem *)value;
- (void)removeItemsObject:(PriceListItem *)value;
- (void)addItems:(NSSet *)value;
- (void)removeItems:(NSSet *)value;
@end
When I attempt to call addItemsObject with the following code a doesNotRecognizeSelector exception is thrown.
PriceListItem *item = [NSEntityDescription insertNewObjectForEntityForName:@"PriceListItem" inManagedObjectContext:managedObjectContext];
item.cat = [attributeDict valueForKey:@"c"];
item.sel = [attributeDict valueForKey:@"s"];
[self addItemsObject:item];
From what I have read I do not have to implement these methods and that they are generated at runtime. Any ideas?
© Stack Overflow or respective owner