Re: CoreData: Inverse relationships not maintained (to-one on one size, to-many on the other, with abstract classes)
Re: CoreData: Inverse relationships not maintained (to-one on one size, to-many on the other, with abstract classes)
- Subject: Re: CoreData: Inverse relationships not maintained (to-one on one size, to-many on the other, with abstract classes)
- From: Jim Correia <email@hidden>
- Date: Tue, 31 May 2005 17:12:04 -0400
On May 31, 2005, at 3:15 PM, Jim Correia wrote:
I have a data model with abstract entities in the hierarchy. The
Item object knows about its root container (to one relationship),
and the container object knows about its items (too many
relationship.)
If I manually set the value for one side of the relationship, the
other side isn't maintained automatically. I've built a fictitious
app which demonstrates the problem.
I did some more digging.
If I run the following code:
// now let's poke at the entities and see what there is to be
learned about the relationships
NSEntityDescription *libraryItemEntity = [NSEntityDescription
entityForName: @"LibraryItem" inManagedObjectContext: context];
NSEntityDescription *libraryNodeEntity = [NSEntityDescription
entityForName: @"LibraryNode" inManagedObjectContext: context];
NSLog(@"%@", [[libraryItemEntity relationshipsByName]
objectForKey: @"root"]);
NSLog(@"%@", [[libraryNodeEntity relationshipsByName]
objectForKey: @"items"]);
At runtime I get:
2005-05-31 17:07:55.582 BrokenInverseRelationships[8826]
(NSRelationshipDescription), name root, isOptional 0, isTransient 0,
entity LibraryItem, validation predicates (), warnings (),
destination entity RootNode, inverseRelationship items, minCount 1,
maxCount 1
2005-05-31 17:07:55.582 BrokenInverseRelationships[8826]
(NSRelationshipDescription), name items, isOptional 1, isTransient 0,
entity LibraryNode, validation predicates (), warnings (),
destination entity LibraryItem, inverseRelationship (null), minCount
0, maxCount 0
The inverse relationship for the Library node, items relationship is
(null) in the output, which is awfully suspicious looking.
(Especially given that the inverse is set in the data model.
Have I bumped into a bug? I can write it up if necessary. (If I have
and there is a ready workaround, I'm all ears.)
Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden