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?
self
in this context is a subclass of PriceList.
I think that the problem is that I am not initializing the PriceList object appropriately.