Re: NSSplitView: Many subviews and ViewControllers, best practices
Re: NSSplitView: Many subviews and ViewControllers, best practices
- Subject: Re: NSSplitView: Many subviews and ViewControllers, best practices
- From: Graham Cox <email@hidden>
- Date: Wed, 22 May 2013 08:48:54 +1000
On 21/05/2013, at 6:39 PM, Trygve Inda <email@hidden> wrote:
> In one pane, I need to have three different views supported by an NSBox that
> I can swap the views out (for icon, thumbnail and list view modes). These
> views all need access to the same NSArrayController.
Have you considered using a tabless NSTabView? For view swapping they are usually a bit easier to deal with than managing it yourself and it naturally leads to an answer to the rest of your post...
> What is the best way to structure this?
>
> Should I have an NSViewController and nib for each pane?
I'd just put it all in one nib. While it can become large, it's very unlikely you'll run into obvious performance problems. If it's in one nib, then hooking everything together becomes a perhaps lengthy but essentially trivial exercise, leaving you with only the task of writing the controller logic and not a whole lot of potentially troublesome view management logic.
Depending on the complexity of your views, a separate controller might be best for each, or a single controller than knows about the different aspects of the data. Or a combination of the two - in similar circumstances I've ended up with a separate controller for each view type, and a master controller that refers to an instance of the separate controller, whichever is needed for the currently active view(s). By designing a common protocol or API for the subcontrollers, the master controller can treat every one the same, regardless of what view type the user chooses.
--Graham
_______________________________________________
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