Insert new relationship data in core data
Posted
by michael
on Stack Overflow
See other posts from Stack Overflow
or by michael
Published on 2010-04-06T12:06:11Z
Indexed on
2010/04/06
13:23 UTC
Read the original article
Hit count: 424
Hoping someone can shed some light on what I might be doing wrong here.
Trying to add an "event" to a list of events, represented by a one to many (inverse) relationship:
MyEvents <--->> Event
This is the code:
MyEvents *myEvents = (MyEvents *)[NSEntityDescription insertNewObjectForEntityForName:@"MyEvents" inManagedObjectContext:context];
NSLog(@"MYEVENTS: %@", myEvents);
NSLog(@"EVENT: %@", event);
[myEvents addEventObject:event];
My context is fine, and both the myEvents
and event
print perfectly valid information.
When I try to add the event that I have (which is passed into this view controller, having been retrieved from core data previously) with this code
[myEvents addEventObject:event];
It falls over with
*** -[NSComparisonPredicate evaluateWithObject:]: message sent to deallocated instance
MyEvents
and Event
are just the default generated code. MyEvents
contains only the relationship to event.
Thanks.
© Stack Overflow or respective owner