Singleton ADC example - dealloc and assignment
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