Реализация шаблона проетирования "Одиночка" на Objective-C выглядит следующим образом.
AuthManager.h
#import <Foundation/Foundation.h> @interface AuthManager : NSObject @property (nonatomic, assign) long long currentUserId; @property (nonatomic, copy) NSString *springSecurityToken; +(AuthManager *) sharedInstance; @end
AuthManager.m
#import "AuthManager.h" @implementation AuthManager @synthesize currentUserId; @synthesize springSecurityToken; +(AuthManager *)sharedInstance { static dispatch_once_t once; static AuthManager *sharedInstance = nil; dispatch_once(&once, ^{ sharedInstance = [[self alloc] init]; }); return sharedInstance; } @end