Re: Addressing Relationships in awakeFromInsert
Re: Addressing Relationships in awakeFromInsert
- Subject: Re: Addressing Relationships in awakeFromInsert
- From: Frédéric Testuz <email@hidden>
- Date: Thu, 11 Aug 2005 13:29:13 +0200
Le 11 août 05 à 00:33, August Trometer a écrit :
Sorry for not being clear. I guess I'm not explaining this
properly, so I'll try again with more detail.
I've got 2 Entities: Show and Episode.
In my model, I've defined an inverse relationship between Show and
Episode, so that a Show has a to-many relationship (called
"episodes") with the Episode entity, and Epsiode has a to-one
relationship (called "show") with the Show entity. The relationship
from Show to Episode is optional, while the relationship from
Episode to Show is not (since you can't have an Episode without a
Show).
When I create a Show, everything is fine -- I can edit, update,
whatever. I'm not wanting Episodes to be created when a Show is
created, nor am I wanting a Show to be created when an Episode is.
In my UI, I'm using a contentSet to define what Episodes show show
in my list, based on the Show that is selected. This all works fine.
So, now I add an Episode for a particular show. Because everything
works up to this point -- episodes for a certain Show only appear
when that particular Show is selected -- I'm assuming that the
relationship does exist between Episode and Show. I want to take
advantage of that when the Episodes are created. That's where
awakeFromInsert comes in.
I think you can have this without a line of code. I did it this week-
end for entities relationships Book<-->>Role.
In your UI, you have two array controller.
1. ShowArrayController, with managedObjectContext binding set and
Automatically prepares content on.
2. EpisodeArrayController, with managedObjectContext set, contentSet
binding set to ShowArrayController.selection.episodes and
Automatically prepares content off.
3. A button with its action set to EpisodeArraController.add:
(add also table views, edit fields, etc.)
And all works.
Frédéric
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden