在ios4之后出现了一种单例的写法:
首先创建一个继承于NSObject的类
在.h文件中声明一个类方法
+ (InstallStatisticsClass *)shareInstance;
在.m中将这个方法
+ (InstallStatisticsClass *)shareInstance
{
static InstallStatisticsClass *instance = nil;
static dispatch_once_t str;
dispatch_once (&str,^{
instance = [[super allocWithZone:nil] init];
});
return instance;
}
原文:http://www.cnblogs.com/anyezhuixing/p/4092454.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!