NSWindowController usage question
NSWindowController usage question
- Subject: NSWindowController usage question
- From: Ricky Sharp <email@hidden>
- Date: Thu, 14 Oct 2004 09:09:15 -0500
I'm writing an application "shell" to serve as the foundation of all my apps. Such apps are all kiosk-like and are made up of one and only one window. The contents of the window will be dynamically set to represent "screens".
As a simple example, consider the following:
Upon launch, you get a window whose contents represent "screen 1". Say that the screen contains a single button "Go to screen 2". Clicking that button will unload the current content view and load the new one which reprents "screen 2".
Here's what I'm planning to do:
MainMenu.nib will contain the owner (NSApplication), AppController (delegate of the owner) and the main menu.
Separate nibs will be created; one for each of my "screens". These nibs will contain the owner (custom NSWindowController), NSPanel containing all the UI, and a custom controller (delegate of the panel). The nib that represents the starting screen (i.e. the screen that is shown when the app is launched) will always have the name MainScreen.nib.
In my app controller, applicationDidFinishLaunching: will manually create an NSWindow (my singleton window) and center it. I then want to load the MainScreen nib, access the NSPanel's contentView and set that as the content view of the singleton window.
I plan on having the following static method in my AppController to provide such a "go to screen" function:
+ (void)gotoScreen:(NSString*)screenName
The implementation would then need to...
- load the nib with the given name and intantiate the window controller
- window controller loads the panel
- panel's content view is obtained which is then set as the content view of the main window
But here is where I'm wondering if I need to have either an NSWindowController object in all these nibs. Would I be better served in having these nibs have an owner which is the controller of the screen (i.e. delegate of the panel)? Put another way, is having a window controller here just an extra layer that really isn't needed? I imagine that without the controller, the implementatio nof gotoScreen: would be more like this:
- load the nib with the given name
- somehow access the panel
- etc.
I've been searching for sample designs similar to what I'm trying and cannot find any. All references either deal with the NSDocument architecture or applications that have multiple windows. Again, I'll only have a single window, but it's contents can come from many different nibs.
Hope this all made sense,
Rick Sharp
Instant Interactive(tm)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden