Re: Examples or Documentation for Non-document-based Multi-window App
Re: Examples or Documentation for Non-document-based Multi-window App
- Subject: Re: Examples or Documentation for Non-document-based Multi-window App
- From: Ken Thomases <email@hidden>
- Date: Wed, 11 Mar 2009 01:27:19 -0500
On Mar 10, 2009, at 5:09 PM, Grant Erickson wrote:
Does anyone have any recommendation for examples, URLs or books that
might
discuss and illustrate such an application or the rough framework
thereto?
I don't have a good resource to point you to, but here's the rough
framework you were looking for:
* Each type of window should be stored in its own NIB. You don't need
a separate NIB for each individual window, just one for each different
type of window (different purpose, layout, etc.).
* The File's Owner for each NIB should be an NSWindowController or
subclass
* You may want a custom NSWindowController subclass, depending on your
needs
* You should connect the "window" outlet of the File's Owner to the
window object in your NIB
* When you want a new window to show up, you allocate and initialize
an instance of NSWindowController or your subclass thereof. You
specify the NIB name as part of initialization. Then, you invoke -
showWindow: on that instance. Alternatively, you can invoke -window
on it and do anything with the window object that you like.
Within the NIB, you can bind the values of various views and controls
to and through File's Owner, which is the window controller object.
That way, each window can display different content. For this, you'd
probably want a custom subclass of NSWindowController so that you can
provide the sorts of data that's specific to your application.
If you're not yet up to using bindings, you can set up the initial
values for views and controls in the -awakeFromNib method of your
custom window controller class. You'll need to establish outlets from
the window controller to the various views, and connect them in the
NIB. Later, as the controller has new values, it will have to
explicitly pass those new values to the relevant views/controls.
Similarly, you would connect actions from controls in the NIB to the
relevant target. That might be File's Owner, First Responder, the
Application object, or something else.
You can search the documentation for terms I've mentioned to learn more.
Cheers,
Ken
_______________________________________________
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