Re: singleton design pattern
Re: singleton design pattern
- Subject: Re: singleton design pattern
- From: Alastair Houghton <email@hidden>
- Date: Wed, 19 May 2010 10:02:12 +0100
On 18 May 2010, at 23:58, Abhinay Kartik Reddyreddy wrote:
> static NSMutableDictionary* uniqueInstance = nil;
> // the static variable has to be initialized before you enter the uniqueInstance method.
Not true. Static variables are initialised to nil (or zero) automatically (it says so in the C standard, §5.1.2 - "All objects with static storage duration shall be initialized (set to their initial values) before program startup."). Further, it's entirely acceptable to write the static variable declaration inside the +uniqueInstance method... that controls the scope of the variable name, not its lifetime (which was already defined by the use of the "static" keyword).
Neither of those things are the problem... as Mike says, we'd need a stack backtrace to see where the problem lies, and it doesn't look as if it's in this method.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden