I have a CoreData object Player with a to-many relationship to goals. I am trying to add a goal object like so,
Goal *fg =(Goal*)[self.database createGoalObject]; //Custom function
Player* player = (Player*)[NSEntityDescription insertNewObjectForEntityForName:@"Player" inManagedObjectContext:self.database.managedObjectContext];
[player addGoalsObject:fg];
My app is breaking with the following error:
'NSInvalidArgumentException', reason: '-[__NSCFSet entity]: unrecognized selector sent to instance 0x8d90f00'
A po at the debug prompt shows that 0x8d90f00 is a Goal object. My questions are:
- why is core data sending a message to the Goal object?
- why is the goals relationship for Player initializing to nil? Should it not be an empty set till loaded?
- Do I have to override the addGoalsObject in Player.h to manually set the value?