• 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
Singleton ADC example - dealloc and assignment
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Singleton ADC example - dealloc and assignment


  • Subject: Singleton ADC example - dealloc and assignment
  • From: email@hidden
  • Date: Wed, 23 Jan 2008 01:44:11 -0800

Hi

Singleton in java is what I am used to, therefore is the cocoa approach confusing to me. Red the example at ADC.
Now I don't understand how one can dealloc the Singleton in an elegant way. With some kind of retain count?

Please see example:
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_10.html

Further I don't understand when the singletone holder point shall be assigned. In the ADC example:
Please see ADC comment  "assignment not done here"

static MyGizmoClass *sharedGizmoManager = nil;
+ (MyGizmoClass*)sharedManager
{
    @synchronized(self) {
        if (sharedGizmoManager == nil) {
            [[self alloc] init]; // assignment not done here
        }
    }
    return sharedGizmoManager;
}


In Java I would be used to code something like:

+ (MyGizmoClass*)sharedManager
{
    @synchronized(self) {
        if (sharedGizmoManager == nil) {
            sharedGizmoManager  = [[self alloc] init];
        }
    }
    return sharedGizmoManager;
}


THX
_______________________________________________

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

  • Follow-Ups:
    • Re: Singleton ADC example - dealloc and assignment
      • From: "Shawn Erickson" <email@hidden>
    • Re: Singleton ADC example - dealloc and assignment
      • From: Jonathon Mah <email@hidden>
  • Prev by Date: Re: Understanding the inner workings: getting to know how functions are called
  • Next by Date: Re: Singleton ADC example - dealloc and assignment
  • Previous by thread: Re: How to with NSCollectionView?
  • Next by thread: Re: Singleton ADC example - dealloc and assignment
  • Index(es):
    • Date
    • Thread