Re: Simple NSWindowController (or window in secondary nib)
Re: Simple NSWindowController (or window in secondary nib)
- Subject: Re: Simple NSWindowController (or window in secondary nib)
- From: Trygve Inda <email@hidden>
- Date: Sun, 07 Feb 2010 06:05:24 +0000
- Thread-topic: Simple NSWindowController (or window in secondary nib)
>> 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.
>
I think a sheet would work just as well... In either case the columns will
not adjust until the use clicks OK.
My thought was to bind the checkboxes to BOOLs in a MutableDict within the
TableController. Once the sheet is dismissed, I would just have the
TableController read the state of the BOOLs and show/hide columns as needed.
This MutableDict would later be saved to disk in the pref file so it'd be
remembered at each launch.
I would just need to operate on a copy of the real BOOLs (so Cancel would
work), and have actions in the TableController for OK/Cancel.
So maybe I don't need a separate controller and can just call
[NSApp beginSheet:checkSheet modalForWindow:mainWindow modalDelegate:self
didEndSelector:@selector(checkSheetDidEnd:returnCode:contextInfo:)
contextInfo:nil];
Thoughts?
Trygve
_______________________________________________
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