objective-c question/clarification
objective-c question/clarification
- Subject: objective-c question/clarification
- From: email@hidden
- Date: Mon, 25 Jun 2001 01:40:16 -0400
I was working through the rest of ToDo example from the O'Reilly Cocoa
and the code snippet below bothered me as there seems to be a hole in my
obj-c knowledge. The first line in the code declares a static local
variable "InfoWindowController" which it then proceeds to set to nil.
The subsequent "if" statement checks to see if the
"InfoWindowController" is pointed at anything. Wouldn't
"InfoWindowController" always be nil thus allowing for the creation of
numerous "info windows" (which I know does not happen). I'm just curious
as to the mechanism behind this code, why it works.
From InfoWindowController.m
+ (id)sharedInfoWindowController
{
static InfoWindowController *_sharedInfoWindowController = nil;
if (!_sharedInfoWindowController)
_sharedInfoWindowController = [[InfoWindowController
allocWithZ$
return _sharedInfoWindowController;
}
Thanks,
Ryan Cuprak
-----------------------------------------------------------------------------------------
Ryan Cuprak <email@hidden> www.cuprak.net
(860)-742-5561
46 Prospect St.
Coventry, CT 06238
-----------------------------------------------------------------------------------------