• 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
objective-c question/clarification
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
-----------------------------------------------------------------------------------------


  • Follow-Ups:
    • Re: objective-c question/clarification
      • From: <email@hidden>
    • Re: objective-c question/clarification
      • From: Carlos Weber <email@hidden>
    • Re: objective-c question/clarification
      • From: Raphael Sebbe <email@hidden>
    • Re: objective-c question/clarification
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: Re: PB widget
  • Next by Date: Re: NSScanner searches from start
  • Previous by thread: Re: NSOutlineView --> NSTextView
  • Next by thread: Re: objective-c question/clarification
  • Index(es):
    • Date
    • Thread