Hi all,
As I come from java world, I was trying to implement the singleton
pattern, very usual in java. After searching in internet I found this
code from wikipedia:
@interface MySingleton : NSObject
{
}
+ (MySingleton *)sharedSingleton;
@end
@implementation MySingleton
static MySingleto
This question usually gets asked at least a couple times a month. I
suggest you look up the previous responses on CocoaBuilder (http://www.cocoabuilder.com/
), which archives responses on this mailing list if you want an
exhaustive response, since all solutions have been mentioned somewhere
Singleton implementation is something that you see debated back and
forth every now and then. People argue about the values over
overriding -retain, -release, -autorelease, and so on.
I really like Peter Hosey's analysis (and implementation) that he's
posted on his blog:
http://boredzo.o
About the only thing that I'd recommend is that the "static" be inside
the +sharedSingleton method so that you aren't able to take the cheap-
way-out and call that variable directly in other class methods before
it's created.
For the rest of it: it seems to follow Apple's patterns - for
in
Definition of true singleton is generally discouraged and not really
useful.
See more info about it here:
http://eschatologist.net/blog/?p=178
Le 10 sept. 2009 à 22:07, Manuel Grau a écrit :
Hi all,
As I come from java world, I was trying to implement the singleton
pattern, very usual i
Probably best to use Apple's example:
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW32
I love Google, but I always prefer to look at Apple's docs first. I
found the above by going to de