Ok so i'm still quite new to iOS and confused about a few things. Firstly, here are my entities...
What i have already in there data wise is a Fruit (Apple) and a Source (Tree). They are both saved in the database.
Next i want to add an orange, but have the relationship with 'Tree'. So this is what i am using:
Fruit *fruit = (Fruit *)[NSEntityDescription insertNewObjectForEntityForName:@"Fruit" inManagedObjectContext:managedObjectContext];
fruit.fruitName = @"Orange";
NSSet *test = [NSSet setWithObject:fruit];
[_source addSourceFruit:test];
NSLog(@"4");
fruit.fruitSource = _source;
(_source is the 'Tree', I performed a fetch request for 'Tree' on the Source entity into an array, then took objectAtIndex:0 (Tree) and assigned it to a point towards source entity.
data = [managedObjectContext executeFetchRequest:request error:&error];
Source *_source = [data objectAtIndex:0];
and the accessor methods:
- (void)addSourceFruitObject:(Fruit *)value;
- (void)removeSourceFruitObject:(Fruit *)value;
- (void)addSourceFruit:(NSSet *)values;
- (void)removeSourceFruit:(NSSet *)values;
I have found an answer relating to bundles but i'm not entirely sure about them. I have read this 'https://developer.apple.com/library/mac/#documentation/CoreFOundation/Conceptual/CFBundles/AboutBundles/AboutBundles.html' and 'https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdAccessorMethods.html' but i just don't seem to be grasping it brilliantly.
EDIT: The error is
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSSet intersectsSet:]: set argument is not an NSSet'
*** First throw call stack: