Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,9 @@
// SomeSingleton.h
@interface SomeSingleton : NSObject
{
// any instance variables
}
+ (SomeSingleton *)sharedInstance;
@end

View file

@ -0,0 +1,38 @@
// SomeSingleton.m
@implementation SomeSingleton
+ (SomeSingleton *) sharedInstance
{
static SomeSingleton *sharedInstance = nil;
if (!sharedInstance) {
sharedInstance = [[SomeSingleton alloc] init];
}
return sharedInstance;
}
- (id)copyWithZone:(NSZone *)zone
{
return self;
}
- (id)retain
{
return self;
}
- (unsigned)retainCount
{
return UINT_MAX;
}
- (oneway void)release
{
// prevent release
}
- (id)autorelease
{
return self;
}
@end

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;
}