0
votes

I am having an issue with core data many to many relationship. I have two entity Menus <<---->> Categories. I can insert data on both the entities. But when I tried to establish a relationship between them, I used this code:

[menu addToCategoriesObject:catagory];

And it crashes with the following error :

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI addToCategoriesObject:]: unrecognized selector sent to instance 0x8fca680'

Your help is appreciated. Also, if there is any good tutorial on Core Data many to many relationship, please share it.

Thanks.

2

2 Answers

1
votes

menu seems to be an NSDictionary object. NSDictionary does not know the method addToCategoriesObject.

You need to establish the relationship by calling the methods on your generated NSManagedObject subclasses, for example something like addManyCategories:(NSSet *)value.

0
votes

The problem was I kept my data in NSDictionary instead of NSManagedObject subclass object. NSDictionary changed its format. So when I tried to add it by addToCategoriesObject method it crashed!!