Looking for some help with pointers and core data, i'll try and explain with a simple example.
Lets say I have a core data managed object called MOAdult which has 1 String attribute called 'name' and 1 NSDecimal Number attribute called 'age'.
I have another managed object called MOChild which also has 1 String attribute 'name', and 1 NSDecimal Number attribute called 'age'.
(I know I would normally subclass here but i'm not for this demo)
I have a 1 to many relationship between MOAdult and MOChild which creates a set which I'll call 'children'. The MOAdult also has a 1 to 1 relationship with itself which i'll called 'marriedTo'.
So...
//I Create 2 adults
MOAdult *father = create object in core data.......
father.name = @"Bob";
father.age = 47; //obviously creating a NSDecimalNumber
MOAdult *mother = create object in core data.......
mother.name = @"Mary";
mother.age = 42; //obviously creating a NSDecimalNumber
//create the marriage relationship
father.marriedTo = mother;
//I create a child object
MOChild *child = create object in core data.......
child.name = @"Billy"
child.age = 7; //obviously creating a NSDecimalNumber
//add the child to the father
[father addChildObject:child];
Now, when I add child to the father object, I want my application to recognise the adult is married by looking at that relationship (father.marriedTo) and if its not null, add the same child object to the mother objects Children Set.
So in effect, both the Father and Mother MOAdult object have the same MOChild object in their Children Set and any change to the Child object is reflected in both the mother and fathers set.
I'm assuming this is best done either through KVO on the set within the MOAdult object, or within the addChildObject method?
Still getting to grips with core data so any advice appreciated.