On 07/02/2010, at 4:33 PM, Trygve Inda wrote:

> I haven't really done a project quite like this before and in the past I
> have used a separate nib for each window.


A separate nib for every distinct window is a good idea. But often a sheet is 
an auxiliary to some other more important window - in this case, putting more 
than one window into a single nib is definitely simplest. The rule-of-thumb I 
tend to follow isn't one window == one nib, but one INTERFACE == one nib, where 
the interface for a given task might have a window plus some other windows, 
typically sheets.

I assumed the column checkboxes window would be a sheet rather than a modal 
dialog. A sheet is definitely a nicer way to handle this.

> So it's window controller would just be a plain NSWindowController (no
> subclass) and in my TableController id just do:
> 
> returnCode = [NSApp runModalForWindow:[theWindController window]];

It might or might not be a plain NSWindowController. Given the situation you 
described, it seems as though you need it to work with your main table view 
controller to set up which columns are displayed. Thus you'll need some 
communication between that controller and the column sheet controller which 
suggests that the column sheet controller is likely to be a subclass of 
NSWindowController.

There's more than one way to do this - you could just wait until the sheet is 
closed and have the tableview controller be its modal delegate, which can read 
the checkbox states, but that means your tableview controller is going to have 
to deal with the UI of the sheet as well as its own. A better design is to 
separate the two things into two controllers, so that on completion the column 
sheet controller calls the tableview controller (as a delegate, maybe) and 
passes it information about which columns are shown or hidden in a form 
abstracted from the UI itself. That leaves the column controller free to 
implement its UI however it wants - e.g. checkboxes one day and a list another 
without changes needed to the tableview controller. How the two controller 
communicate is up to you - as they're both custom subclasses you can make them 
cooperate however you want.

--Graham


_______________________________________________

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