• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Core Data can't do Distinct Relationships to Same Entity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data can't do Distinct Relationships to Same Entity


  • Subject: Core Data can't do Distinct Relationships to Same Entity
  • From: Jerry Krinock <email@hidden>
  • Date: Tue, 22 Jun 2010 19:12:09 -0700

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 (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

  • Follow-Ups:
    • Re: Core Data can't do Distinct Relationships to Same Entity
      • From: Roland King <email@hidden>
  • Prev by Date: Initiating drag and drop from NSToolbarItem
  • Next by Date: Re: Initiating drag and drop from NSToolbarItem
  • Previous by thread: Re: Initiating drag and drop from NSToolbarItem
  • Next by thread: Re: Core Data can't do Distinct Relationships to Same Entity
  • Index(es):
    • Date
    • Thread