标签:style color io os ar strong div sp log
写一个类 起作用是 传值
#import <Foundation/Foundation.h>
@interface singleton : NSObject
+(singleton *)shareData;
@property (strong, nonatomic) NSString *value;
@end
#import "singleton.h"
@implementation singleton
static singleton *singletonData = nil;
+(singleton *)shareData {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
singletonData = [[singleton alloc] init];
});
return singletonData;
}
-(id)init {
if (self = [super init]) {
}
return self;
}
@end
singleton *oneS = [singleton shareData];
oneS.value = @"my name is caomao";
NSLog(@"oneS.value---->%@",oneS.value);
值已经赋好啦 。。。NSString *strB = [singleton shareData].value];
标签:style color io os ar strong div sp log
原文地址:http://blog.csdn.net/u013682799/article/details/39289491