I have a simple Parent Child relationship. The relationship is ordered. I have created NSManagedObject Subclasses for each entity. When I attempt to add a Child to the Parent's Chilren ordered Set. I receive the follow error: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSSet intersectsSet:]: set argument is not an NSSet'.
Here is the relevant code:
CDParent.h
@interface CDParent : NSManagedObject
@property (nonatomic, retain) NSOrderedSet *children;
@end
@interface CDParent (CoreDataGeneratedAccessors)
// snip
- (void)addChildrenObject:(CDChild *)value;
// snip
@end
CDChild.h
@class CDParent;
@interface CDChild : NSManagedObject
@property (nonatomic, retain) CDParent *parent;
@end
CDAppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
CDParent *parent = [NSEntityDescription insertNewObjectForEntityForName:@"Parent" inManagedObjectContext:self.managedObjectContext];
CDChild *child = [NSEntityDescription insertNewObjectForEntityForName:@"Child" inManagedObjectContext:self.managedObjectContext];
[parent addChildrenObject:child]; // <- CRASH
// SNIP
}
This seems very straight forward. I must be missing something very basic because I can't find any answers on the ole internet.
Thanks!