Re: Proper way to create a singleton without @synchronized ?
Re: Proper way to create a singleton without @synchronized ?
- Subject: Re: Proper way to create a singleton without @synchronized ?
- From: WT <email@hidden>
- Date: Sun, 17 Apr 2011 16:04:03 -0300
On Apr 17, 2011, at 3:52 PM, Joanna Carter wrote:
> Hi guys
>
>> That's only because, unlike java, obj-c doesn't have a way built into the language to enforce a class to be abstract. I can see valid reasons to subclass a singleton if that singleton is to be used as an abstract class and never be instantiated by itself.
>
> Tell me; maybe it's my background in other languages, but I would tend to use a "static class" as a singleton; or, at least, design a class with only class methods/properties, with static "fields" declared in the @implementation section of a class.
>
> Why this fascination with going to all the trouble of creating a singleton rather than using the "static class" approach?
>
> Joanna
Hi Joanna,
not a fascination, but simply a preference and being used to coding that way. As for the "static class" idea, what happens if you need/want to subclass that class? Then you have to search for and change all the places in your code base that refer to it.
WT_______________________________________________
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