/*
*单例的概念:定义一个类,如果需要设计模式是个单例。那么,我们在实例化时,有且只有一个对象。
*作用的作用:方便任何对象共享和访问这个实例。
*/
static instenceClass *class = nil;
+ (instenceClass *)shareClass
{ //加锁
@synchronized(self) { //保证单例创建的唯一性
if (class == nil) {
class = [[instenceClass alloc] init];
}
}
return class;
}
+ (id)allocWithZone:(struct _NSZone *)zone
{
@synchronized(self){
if (class == nil) {
class = [super allocWithZone:zone];
return class;
}
return class;
}
}//分配空间
- (id)copyWithZone:(NSZone *)zone
{
return self;
}
/********************* MRC ***************************/
- (oneway void)release
{
}
- (NSUInteger)retainCount
{
return INT32_MAX;
}
- (id)autorelease
{
return self;
}
- (id)retain
{
return self;
}