Re: Several Cocoa questions
Re: Several Cocoa questions
- Subject: Re: Several Cocoa questions
- From: "Erik M. Buck" <email@hidden>
- Date: Wed, 27 Feb 2002 12:57:33 -0600
- Organization: EMB & Assocites Inc.
Here are the answers typed into Mail so slight inaccuracies may arise.
>
1) Closing the app from a button - If there is an Off or Close button in
>
the program window, what code is necessary to tell the program to shut
>
down? In Java, this would be fairly simple with a command like:
[NSApp terminate:nil];
>
>
System.exit(0);
>
>
But I am using just Objective-C Cocoa, no Java.
>
>
2) How can I create multiple instances/windows of my program? Do I just
>
create a function which allocates a new instance of the program and that
>
handles most of the problems?
[[NSBundle mainBundle] loadNibNamed:@"someNibName"];
>
>
3) When the last window of the program is closed, what code is necessary
>
to tell the entire program to shut down? Also, how would I link in this
>
information to my interface, if necessary?
>
Implement the following in the application's delegate:
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication
*)theApplication
Invoked when the user closes the last window the application has open.
If this method returns NO, the application is not terminated, and control
returns to the main event loop. Return YES to allow the application to
terminate. Note that applicationShouldTerminate: is invoked if this method
returns YES.
>
Thanks for any help.
>
All of these questions are easily answered by RTFM. If you don't understand
nib files or bundles or the application object or delegates, there are many
introductory tutorials available on the net.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.