Next: 2.5.1 The organization of Up: 2 Adding a Window Previous: 2.4 Ordering Front a

2.5 Integrating the window with your application

We now want to show a very simple example of an application creating a single window. Our application will be useless if its only window is not visible; for this reason, we do not add a close button to the window (following the NEXTSTEP tradition, the user needs to select Quit from the main menu to quit the application. To get the main menu, the user typically clicks the right button of his mouse on one of the windows).

We can create the window in the same method

- (void) applicationWillFinishLaunching: (NSNotification *)not;
where we created the menu. This method contains initialization code to be run before the application is launched.

But, we can't order front (ie, make visible) windows before NSApp has become active (which happens when the application is `launched'), so that ordering front our window in applicationWillFinishLaunching: would not work, because this method is called before the application finished launching.

To get around this problem, we implement in our application delegate also another method, called:

- (void) applicationDidFinishLaunching: (NSNotification *)not;
This method (if implemented by the application's delegate) is invoked by the NSApp just after it finished launching. We order front our window in this method.



Subsections
Next: 2.5.1 The organization of Up: 2 Adding a Window Previous: 2.4 Ordering Front a
2008-01-16