利用GCD构建
DataCenter.h
#import
@interface DataCenter:NSObject
+(id)sharedDataCenter;
@end
DataCenter.m
#import “DataCenter.h”
@implementation DataCenter
+(id)sharedDataCenter{
static DataCenter *sharedDataCenter=nil;
static dispatch_once_t token;
dispatch_once(&token, ^{
sharedDataCenter = [[self alloc]init];
});
return sharedDataCenter;
}
网友评论