• 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
Re: Singletons with ARC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Singletons with ARC


  • Subject: Re: Singletons with ARC
  • From: Uli Kusterer <email@hidden>
  • Date: Fri, 09 Dec 2011 10:46:24 +0100

On Dec 9, 2011, at 6:18 AM, Abdul Sowayan wrote:
> + (MyClass *)sharedInstance
> {
>  static MyClass *sharedInstance = nil;
>
>  if(sharedInstance == nil)
>  {
>    @synchronized(self)
>    {
>      if (sharedInstance == nil)
>      sharedInstance = [[self alloc] init];
>    }
>  }
>
>  return sharedInstance;
> }


Ah, wait. Somehow I misread that code. Nevermind my question about whether this occurs in practice, but thanks go to Jean-Daniel and Andreas for their answers. It's nice to know more about this. I guess I'm still wary about the whole "an assignment may not be an atomic operation" thing on older CPUs that I did it right "by accident" :-)

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."

_______________________________________________

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

References: 
 >Singletons with ARC (From: Ben <email@hidden>)
 >RE: Singletons with ARC (From: Abdul Sowayan <email@hidden>)

  • Prev by Date: Re: Singletons with ARC
  • Next by Date: Re: How to initiate drag&drop for a filename outside of NSView mouseDown
  • Previous by thread: Re: Singletons with ARC
  • Next by thread: Re: Singletons with ARC
  • Index(es):
    • Date
    • Thread