多线程单例.h
#import <Foundation/Foundation.h>
@interface DataHandle : NSObject
+ (DataHandle *)defaultdataHandle;
@end
多线程单例.m
#import "DataHandle.h"
@implementation DataHandle
+ (DataHandle *)defaultdataHandle
{
static DataHandle *dataHandle = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
dataHandle = [[DataHandle alloc] init];
});
return dataHandle;
}
@end