Re: applicationShouldTerminateAfterLastWindowClosed
Re: applicationShouldTerminateAfterLastWindowClosed
- Subject: Re: applicationShouldTerminateAfterLastWindowClosed
- From: "M. Uli Kusterer" <email@hidden>
- Date: Sun, 8 Feb 2004 15:32:40 +0100
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.