One other thing to keep things simple.. Take all common functionality and put it into a base view controller class. Then subclass from there for any new controls, functionality, setup, etc.

Scott

On Jun 10, 2009, at 7:40 AM, Stephen Blinkhorn wrote:

On 9 Jun 2009, at 22:44, Quincey Morris wrote:

On Jun 9, 2009, at 19:50, Stephen Blinkhorn wrote:

If you must use a tab view, you could also approach it with a view xib and a view controller to define the common part of each tab. The view controller would act as an intermediary to pass the action methods on to the correct controller. (The details, and feasibility, of this approach might depend on exactly what class of controllers you're trying to use.)

That sounds interesting but will involve a near complete overhaul.

Are you sure?

Well, yes and no. I'm writing the GUI for a real time audio program. The back end of that is written in C++ which I've written too. The Cocoa UI is getting quite complex now but is nearly finished so I'm a bit reluctant to tear it apart. It is my first real Cocoa project though so I can't assume I've got it all right first time.


Moving the contents of the tabs to a different xib file (or is it xib files? are all the tabs identical in appearance?) is straightforward. Connecting the individual controls to the view controller (File's Owner) is straightforward. Writing intermediary action methods in your view controller subclass to pass the actions on the correct controller (held in an instance variable, or set as the representedObject) is straightforward.

All my tabs are identical. The current purpose of my controller objects is to map the value from a control onto a nonlinear range. I display the nonlinear value in the UI for user feedback and then pass it to the C++ audio side. There are a number of controls within in each tab(s) which require a custom mapping and differ from controller to controller based on some user selection. Currently I deal with this by dynamically allocating/deallocating a kind of sub controller object of the required type at that time.


The only real work happens in (say) your window controller's awakeFromNib method. In that method, you would create as many view controllers as there are distinct tabs, passing the correct action controller object as a parameter, and letting the view controller instantiate its nib. Then, for each view controller, replace the appropriate tab subview with the view controller's view.

That doesn't require any design changes anywhere else in your application, AFAICT. It also has the advantage of making your life really easy if you ever have to add one more control to all of the tabs.

I know I will be adding and changing things over the next few months so I think it will be worthwhile putting the time in to implement something like this. It isn't so much the tedium of manually connecting things together but the inevitability that a few connections will go astray at some point. I did try something with bindings but it quickly got out of hand for me.

Can I make connections programmatically? That might be easier for now.

Thanks,
Stephen


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/scottandrew%40roadrunner.com

This email sent to scottand...@roadrunner.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to