What does your Objective-C singleton look like?
Posted
by schwa
on Stack Overflow
See other posts from Stack Overflow
or by schwa
Published on 2008-09-28T03:38:53Z
Indexed on
2010/03/15
18:59 UTC
Read the original article
Hit count: 159
Mine is merely (or a close variant thereof):
static MyClass *gInstance = NULL;
+ (MyClass *)instance
{
@synchronized(self)
{
if (gInstance == NULL)
gInstance = [[self alloc] init];
}
return(gInstance);
}
© Stack Overflow or respective owner