I have a Core Data structure with Restaurants and Atmospheres, where a restaurant can have many atmospheres and an atmosphere can have many restaurants. So I made two to-many relationships, both being the inverse of themselves as stated in Apple's Documentation, forming a many-to-many relationship.
However I am having troubles adding objects to the sets created. Example, when I use code such as this one,
Atmosphere *atmosphere = [Atmosphere atmosphere:aId inManagedObjectContext:context];
[restaurant addAtmospheresObject:atmosphere];
it crashes with a weird error:
EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
Has anyone every encountered this please?
Looks like you are not creating your atmosphere
object correctly. Try this:
Atmosphere *atmosphere = [NSEntityDescription
insertNewObjectForEntityForName:@"Atmosphere"
inManagedObjectContext:context];
// further configuration
if (restaurant) {
[restaurant addAtmospheresObject:atmosphere];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With