Reputation: 97
I want to save a Goal and an Actor. The two entities are related with an Responsibility-relationship:
Goal *addgoal = (Goal*)[NSEntityDescription insertNewObjectForEntityForName:@"Goal" inManagedObjectContext:context];
addgoal.goalNaam = nameTextField.text;
addgoal.goalId = idField.text;
addgoal.goalBeschrijving = beschrijvingField.text;
Actor *addactor = (Actor*)[NSEntityDescription insertNewObjectForEntityForName:@"Actor" inManagedObjectContext:context];
addactor.actorNaam = responsibleField.text;
[addgoal addResponsibilityObject:addactor];
the line above ([addgoal addResponsibility:addactor]) is causing the error, what is wrong ?
in Goal.h:
@interface Goal (CoreDataGeneratedAccessors)
- (void)addResponsibilityObject:(Actor *)value;
@end
Error:
2012-08-02 20:57:11.838 Choose3[7434:fb03] -[__NSCFSet entity]: unrecognized selector sent to instance 0x8877810 2012-08-02 20:57:11.840 Choose3[7434:fb03] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFSet entity]: unrecognized selector sent to instance 0x8877810'
Upvotes: 1
Views: 1109
Reputation: 18729
I just encountered the same problem. The solution here was, that I forgot to check the "To-Many" option in the relationship options within the model inspector.
Upvotes: 6
Reputation: 31016
It appears that Core Data is confused about the nature of the Responsibility relationship. I suggest creating NSManagedObject
subclasses that match the current state of your data model.
One way to create this error would be to change a to-many relationship into a to-one relationship without re-generating the entity class files.
Upvotes: 0