标签:
单例究竟怎么传值?今天终于会了
.h
@interface MySharedClass : NSObject
@property (nonatomic, copy) NSString *sharedString;
+ (MySharedClass *)sharedInstance;
@end
.m
@implementation MySharedClass
+ (MySharedClass *)sharedInstance
{
static MySharedClass *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[MySharedClass alloc] init];
});
return sharedInstance;
}
@end
简单应用
[MySharedClass sharedInstance].sharedString
标签:
原文地址:http://www.cnblogs.com/fengkuangIT/p/4861615.html