标签:
@interface initTest : NSObject
@end @interface sub1 : initTest @end @interface sub2 : sub1 @property (nonatomic, strong) NSString *kvoTestStr; @end @interface sub2 (category1) @end @interface sub2 (category2) @end
@implementation initTest
//+(void)initialize //{ // NSLog(@"%s|%@ ",__func__ ,[self class]); //} +(void)load { NSLog(@"%s ",__func__ ); } @end @implementation sub1 +(void)initialize { NSLog(@"%s|%@ ",__func__ ,[self class]); } //+(void)load //{ // NSLog(@"%s ",__func__ ); //} @end @implementation sub2 //+(void)initialize //{ // NSLog(@"%s|%@ ",__func__ ,[self class]); //} +(void)load { NSLog(@"%s ",__func__ ); } @end @implementation sub2 (category1) //+(void)initialize //{ // NSLog(@"%s|%@ ",__func__ ,[self class]); //} +(void)load { NSLog(@"%s ",__func__ ); } @end @implementation sub2 (category2) //+(void)initialize //{ // NSLog(@"%s|%@ ",__func__ ,[self class]); //} +(void)load { NSLog(@"%s ",__func__ ); } @end
|
2015-05-26 13:44:58.757 OCinitTest[80219:72734510] +[initTest load]
2015-05-26 13:44:58.758 OCinitTest[80219:72734510] +[sub2 load] 2015-05-26 13:44:58.759 OCinitTest[80219:72734510] +[sub2(category1) load] 2015-05-26 13:44:58.759 OCinitTest[80219:72734510] +[sub2(category2) load] 2015-05-26 13:44:58.863 OCinitTest[80219:72734510] +[sub1 initialize]|sub1 2015-05-26 13:44:58.863 OCinitTest[80219:72734510] +[sub1 initialize]|sub2
2015-05-26 13:44:58.863 OCinitTest[80219:72734510] +[sub1 initialize]|NSKVONotifying_sub2
|
static MySingleton *sharedSingleton;
+ (void)initialize
{
static BOOL initialized = NO;
if(!initialized)
{
initialized = YES;
sharedSingleton = [[MySingleton alloc] init];
}
}
标签:
原文地址:http://www.cnblogs.com/doudouyoutang/p/4530454.html