Why don't you have a property 'arms' which is a to-many property? If you want to find a specific arm from the body you can iterate the arms looking for the one you want, or in the generic case use a predicate to find it for you. That also scales well when you put Hindu Gods (or Venusians) into your model as they potentially have lots and lots of arms.

Nothing stops you hiding the details of this with a -(Arm*)leftArm and -(Arm*)rightArm method in your body class which just goes and hunts or predicates the arms property to find the one you want.

Jerry Krinock wrote:
Say that I'm modelling a human body.  Each body has two arms, and I model them 
with the same entity; one has, maybe, setFlipped:YES and the other has 
setFlipped:NO.  But they are accessed for different purposes; sometimes I want 
the left arm and sometimes the right arm.  I'd therefore like to set up 
relationships thus:

 Body_Entity        Arm_Entity
     leftArm <----> body
    rightArm <----> body

But Core Data won't let me do this, because the Arm's 'body' relationship can 
only have one inverse relationship.  Instead, I must do this:

 Body_Entity        Arm_Entity
     leftArm <----> bodyLeft
    rightArm <----> bodyBody

which looks kind of silly, and also in order to access 'body' from an Arm 
object I need a silly accessor:

- (Body*)body {
    Body* body = [self bodyLeft] ;
    if (!body) {
        body = [self bodyRight] ;
    }
return body ;
}

Is there a better way to model such a thing?

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org

This email sent to r...@rols.org
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to