Core Data inverse relationships
Core Data inverse relationships
- Subject: Core Data inverse relationships
- From: Gideon King <email@hidden>
- Date: Fri, 7 Aug 2009 23:23:27 +1000
I have a situation where I don't want to have an inverse relationship,
but coredata seems pretty keen on me having inverse relationships for
all relationships. For example, say I have a "picture" managed object,
which has things like the URL, the displayed size and rotation and
caption. Now I have a person object that has a picture, a building
that has a picture, some equipment that has a picture. This implies
that if I had picture in the model, it would have to have one
relationship to person, one to building, and one to equipment - etc,
for everything that could have a picture.
Should I just make it a one way relationship and disable the warning
messages? I understand that this would just mean that whenever I
delete an object that has a picture associated with it, then I would
just have to also delete the picture - anything else to be aware of
(especially for things like undo etc)? I guess I would also want to
fault the picture if its owner was turned to a fault. So far in the
documentation I have just found the recommendation that you don't have
one way relationships, and the very brief section on unidirectional
relationships which isn't clear to me.
Or is there another way to model it so that I can work around this
situation without having this issue? I guess it would be possible to
have an abstract super-class in the model, which has a picture
relationship, but that really doesn't seem like a tidy approach,
especially when you have multiple situations like this with different
relationships, and without multiple inheritance (thank goodness),
you'd probably end up having a nasty uber-super-class with all the
relationships applicable to a subset of the subclasses - yuck. Is
there a workable way to model it so as to have the reverse
relationships?
Thanks
Gideon
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden