Re: Bindings across view controllers in OS X storyboards
Re: Bindings across view controllers in OS X storyboards
- Subject: Re: Bindings across view controllers in OS X storyboards
- From: Fritz Anderson <email@hidden>
- Date: Fri, 01 May 2015 10:58:22 -0500
On 28 Apr 2015, at 6:54 PM, Rick Mann <email@hidden> wrote:
> I have a window made up of a couple of NSSplitViewControllers and custom view controllers. It's mostly a master-detail type of thing, where the selected item in the first split sets up the second, and a selected item there sets up the third.
>
> Thing is, I don't see a good way to bind from one view controller to the other. I could subclass NSSplitViewController, override -prepareForSegue:, and inject references to the NSArrayControllers that way, but that means subclassing NSSplitViewController, which seems rather lame.
I almost devoted half-a-chapter to how disastrous and inexplicable this is, until I figured out the rules. Part of the rant made it through to the page proofs (print minus one).
Storyboards are not monoliths at runtime, they’re an archive of NIBs, one for each view controller. Cross-controller relationships are missing only in the sense that they are impossible. That includes parent-child relationships from window controllers across split-view controllers.
A window controller has a reference to its content controller. Descend that into the split-view controller and index the splits, then recover the content controller for each. In the process, you can propagate the child controllers up to the window controller (or whatever).
— F
_______________________________________________
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