This commit is contained in:
Ingy döt Net 2013-06-05 21:47:54 +00:00
parent 1f1ad49427
commit 6f050a029e
2496 changed files with 37609 additions and 3031 deletions

View file

@ -4,6 +4,6 @@
// any instance variables
}
+ (SomeSingleton*)sharedInstance;
+ (SomeSingleton *)sharedInstance;
@end

View file

@ -1,10 +1,10 @@
// SomeSingleton.m
@implementation SomeSingleton
+ (SomeSingleton*) sharedInstance
+ (SomeSingleton *) sharedInstance
{
static sharedInstance = nil;
if(!sharedInstance) {
static SomeSingleton *sharedInstance = nil;
if (!sharedInstance) {
sharedInstance = [[SomeSingleton alloc] init];
}
return sharedInstance;
@ -25,7 +25,7 @@
return UINT_MAX;
}
- (void)release
- (oneway void)release
{
// prevent release
}

View file

@ -0,0 +1,10 @@
+ (SomeSingleton *) sharedInstance
{
static SomeSingleton *sharedInstance = nil;
@synchronized(self) {
if (!sharedInstance) {
sharedInstance = [[SomeSingleton alloc] init];
}
}
return sharedInstance;
}

View file

@ -0,0 +1,9 @@
+ (SomeSingleton *) sharedInstance
{
static SomeSingleton *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[SomeSingleton alloc] init];
});
return sharedInstance;
}