71 lines
1012 B
Objective-C
71 lines
1012 B
Objective-C
//
|
|
// PNUser.m
|
|
// Pods
|
|
//
|
|
// Created by Giuseppe Nucifora on 15/01/16.
|
|
//
|
|
//
|
|
|
|
#import "PNUser.h"
|
|
|
|
@implementation PNUser
|
|
|
|
static PNUser *SINGLETON = nil;
|
|
|
|
static bool isFirstAccess = YES;
|
|
|
|
#pragma mark - Public Method
|
|
|
|
+ (id)sharedInstance
|
|
{
|
|
static dispatch_once_t onceToken;
|
|
dispatch_once(&onceToken, ^{
|
|
isFirstAccess = NO;
|
|
SINGLETON = [[super allocWithZone:NULL] init];
|
|
});
|
|
|
|
return SINGLETON;
|
|
}
|
|
|
|
#pragma mark - Life Cycle
|
|
|
|
+ (id) allocWithZone:(NSZone *)zone
|
|
{
|
|
return [self sharedInstance];
|
|
}
|
|
|
|
+ (id)copyWithZone:(struct _NSZone *)zone
|
|
{
|
|
return [self sharedInstance];
|
|
}
|
|
|
|
+ (id)mutableCopyWithZone:(struct _NSZone *)zone
|
|
{
|
|
return [self sharedInstance];
|
|
}
|
|
|
|
- (id)copy
|
|
{
|
|
return [[PNUser alloc] init];
|
|
}
|
|
|
|
- (id)mutableCopy
|
|
{
|
|
return [[PNUser alloc] init];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
if(SINGLETON){
|
|
return SINGLETON;
|
|
}
|
|
if (isFirstAccess) {
|
|
[self doesNotRecognizeSelector:_cmd];
|
|
}
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
|
|
@end
|