0
votes

I have a condition where I have many-many for my two entities:

A category can have many places, in other hand, places can be also under many categories

The data are successfully stored in my sqlite, but when I check the structure of both entites in sqlite manager software, the relationship between two of it is gone.

Usually, when I declare 1..* , for example:

Entity B has one entity A

Place is under one category

Category will become an attribute in Place, where I can use it for later use:

Category *category = (Category*)place.category;
NSString *catId = category.catId;

and it should returns a value of catId if there is value there.

But in my many-many case, I can't even get the catId, it crashes like this:

-[_NSFaultingMutableSet catID]: unrecognized selector sent to instance

Do I miss a concept here? I believe core data supports many to many relationship as I've read it in some web. Thanks!

1
Post the code for your Category classtrapper

1 Answers

1
votes

You have a 'to-many' relationship from Place->Category, so place.category is a NSMutableSet object not a Category object

Try this

NSMutableSet *categorySet = place.category;

foreach (Category *category in categorySet)
{
    NSString *catId = category.catId;
    NSLog(@"catId: %@", catId);
}