I cannot seem to figure out the last little bit on how to access layers of a to-many relation in Core Data (DB newbie). All examples are simple 2 entity relation. My Core Data looks like this:
Entity_A
Attribute_AA
Attribute_AB
Relation_AB (to-many from entity_A to entity_B)
Entity_B
Attribute_BA
Attribute_BB
Relation_BA (many-to from entity_B to entity_A)
Relation_BC (to-many from entity_B to entity_C)
Entity_C
Attribute_CA
Attribute_CB
Relation_CB (many-to from entity_C to entity_B)
I've successfully managed to populate the entities and fetch Entity_A into self.entity_A. The self.entity_A.relation_AB shows as faults but I've learnt that's normal and I can NSLog the values in entity_B and entity_C as NSSets using the following statements:
NSLog(@"Entity_B: %@", [self.entity_S.relation_AB valueForKey:@"Attribute_BA"]);
NSLog(@"Entity_C: %@", [[self.entity_A.relation_AB mutableSetValueForKey:@"Relation_BC"] valueForKey:@"Attribute_CA"]);
which gives me the following output that is the correct values stored in the entities in my db:
Entity_B: {(directory1, directory2)}
Entity_C: {(file1, file2, file3)},{(file4, file5, file6, file7)}
(the directory1/2 and file1/2/3/4/5/6/7 are just values stored in the respective entity in the db for example sake)
It seems the lists from NSSets are not linked so how do you know which file in entity_C is with what directory in entity_B is with what thing in entity_A?
Another way of asking is how do I get a "self.entity_A.entity_B.directory1" (this syntax may not be correct) that contains [file1, file2, file3] from the example above and a "self.entity_A.entity_B.directory2" that contains [file4, file5, file6, file7]?
Thanks for your help.
Hiren.