On Wed, Jan 27, 2010 at 1:51 PM, Scott Ribe <scott_r...@killerbytes.com> wrote: > The code you posted has a race condition, and can create multiple instances > when called from different threads.
This is true. My favorite way of avoiding it: + (Foo *)sharedFoo { static Foo *instance; static dispatch_once_t once; dispatch_once(&once, ^{ instance = [[Foo alloc] init]; }) return instance; } --Kyle Sluder _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com