• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: applicationShouldTerminateAfterLastWindowClosed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: applicationShouldTerminateAfterLastWindowClosed


  • Subject: Re: applicationShouldTerminateAfterLastWindowClosed
  • From: Peter Wollschlaeger <email@hidden>
  • Date: Tue, 10 Feb 2004 00:21:06 +0100

I have in mainMenu.nib a controller and I simple control-drag from File's Owner to the instance oft this controller (and connect the delegate in the info window). Then I write the code into controller.m.
Cheers
Peter
Am 09.02.2004 um 03:44 schrieb Steve Palmer:

Out of curiosity, how do you use this delegate? The documentation is not very clear. I set [NSApp setDelegate:self] in my app controller and implemented this delegate, but the delegate never gets called after I close the last visible window. What could I be missing?

- Steve


On Feb 8, 2004, at 2:32 PM, M. Uli Kusterer wrote:

At 13:44 Uhr +0100 08.02.2004, Peter Wollschlaeger wrote:
- (BOOL)applicationShouldTerminateAfterLastWindowClosed: (NSApplication
*) nameOfMyApp
{
// some checks
return YES;
}

Now I just found out that it works well too if I write

- (BOOL)applicationShouldTerminateAfterLastWindowClosed: xyz

where xyz can be id or any other undeclared name. So what is the sense
of this parameter?

If you do not specify a data type for a parameter to an ObjC method, it defaults to id. So, what you are writing is:

-(BOOL) applicationShouldTerminateAfterLastWindowClosed: (id)xyz

ObjC is very tolerant in letting you use other data types for parameters. Also, it doesn't allow any overloading based on the type of parameters. In this respect, Objective C behaves pretty much like C, and not at all like C++.

This has the advantage that, e.g. even though an IBAction is defined as

-(void) foo: (id)sender;

you can also write

-(void) foo: (NSApplication*)sender;

to indicate to those using this method that it should always be an NSApplication that is passed as the sender. However, ObjC doesn't enforce this.

The parameter to applicationShouldTerminateAfterLastWindowClosed: is simply a convenience that gives you a pointer to the application that is wondering whether it should terminate.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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.
_______________________________________________
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.

References: 
 >applicationShouldTerminateAfterLastWindowClosed (From: Peter Wollschlaeger <email@hidden>)
 >Re: applicationShouldTerminateAfterLastWindowClosed (From: "M. Uli Kusterer" <email@hidden>)
 >Re: applicationShouldTerminateAfterLastWindowClosed (From: Steve Palmer <email@hidden>)

  • Prev by Date: Re: Identifying preferencePanes
  • Next by Date: Re: Drawing an NSProgressIndicator inside a custom view
  • Previous by thread: Re: applicationShouldTerminateAfterLastWindowClosed
  • Next by thread: Re: applicationShouldTerminateAfterLastWindowClosed
  • Index(es):
    • Date
    • Thread