Re: applicationShouldTerminateAfterLastWindowClosed
Re: applicationShouldTerminateAfterLastWindowClosed
- Subject: Re: applicationShouldTerminateAfterLastWindowClosed
- From: Steve Palmer <email@hidden>
- Date: Mon, 9 Feb 2004 02:44:22 +0000
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.