1.单例第一种方法
static Manager *manager = nil;
+ (Manager *) shareManagerInit {
if (!manager) {
manager = [[Manager alloc] init];
}
return manager;
}
2.单例第二种方法
static Employee *emp = nil;
+ (Employee *) shareManagerInit {
if (!emp) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken , ^{
emp = [[Employee alloc] init];
});
return emp;
}
}