在OC中,我们通常通过使用GCD的dispatch_once方法实现单例(singleton)
@interface SingletonSample : NSObject
+ (instancetype)sharedInstance;
@end
@implementation SingletonSample
+ (instancetype)sharedInstance {
static dispatch_once_t SingletonSampleOnceToken;
在OC中,我们通常通过使用GCD的dispatch_once方法实现单例(singleton)
@interface SingletonSample : NSObject
+ (instancetype)sharedInstance;
@end
@implementation SingletonSample
+ (instancetype)sharedInstance {
static dispatch_once_t SingletonSampleOnceToken;