• 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
Re: Why is it wrong to have relationships without an inverse in Core Data?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is it wrong to have relationships without an inverse in Core Data?


  • Subject: Re: Why is it wrong to have relationships without an inverse in Core Data?
  • From: Rick Mann <email@hidden>
  • Date: Mon, 24 Jun 2013 10:54:10 -0700

On Jun 24, 2013, at 07:49 , Flavio Donadio <email@hidden> wrote:

> After reading all this thread and watching it deviate from the problem at hand into a philosophical argument, I think it's time to answer the unanswered question...
>
> Rick Mann, I don't understand why you need a separate relationship to retrieve the active Child objects. Please, consider doing this:
>
> Parent
> children     to-many to Child
>
> Child
> parent       to-one to Parent
> active      (boolean)
>
> And then create an activeChildren: method in Parent with returns only the active children.
>
> Sorry if this is not acceptable. I am just trying to help.

It's a fine suggestion, Flavio. I've used it in other places. But it requires better discipline when programming, if there can be only one active child (per parent). You can't just set active to true, you have to also ensure any other active child is set to false. You can create methods for this, and make active a private or read-only property, I suppose. You could even make it a transient property on Parent and just fetch the active child on awake.

Seems easier to have a relation on the parent to enforce this; there's no way to have more than one active child.

--
Rick




_______________________________________________

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


References: 
 >Re: Why is it wrong to have relationships without an inverse in Core Data? (From: Flavio Donadio <email@hidden>)

  • Prev by Date: Re: Core Data Reverse Engineering KickStarter Project
  • Next by Date: Re: How to determine the Http Method type being implemented for web service API
  • Previous by thread: Re: Why is it wrong to have relationships without an inverse in Core Data?
  • Next by thread: Re: Why is it wrong to have relationships without an inverse in Core Data?
  • Index(es):
    • Date
    • Thread