Re: Why is it wrong to have relationships without an inverse in Core Data?
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