标签:
/**load * 当类加载到OC运行环境中(内存),就会调用一次 */ /**initialize * 当第一次使用这个类的时候才会调用 */
#import "Person.h"
@implementation Person
+ (void)load
{
NSLog(@"------------person load--------------");
}
+ (void)initialize
{
NSLog(@"------------person initialize--------------");
}
#import "Child.h"
@implementation Child
+ (void)load
{
NSLog(@"------------Child load--------------");
}
+ (void)initialize
{
NSLog(@"------------Child initialize--------------");
}
#import "ViewController.h"
#import "Person.h"
#import "Child.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//Person *p = [[Person alloc] init];
Child *c = [[Child alloc] init];
}
输出结果
2015-07-19 17:05:59.735 test[27283:1314612] ------------person load--------------
2015-07-19 17:05:59.739 test[27283:1314612] ------------Child load--------------
2015-07-19 17:05:59.928 test[27283:1314612] ------------person initialize--------------
2015-07-19 17:13:05.182 test[27396:1319499] ------------Child initialize--------------
标签:
原文地址:http://my.oschina.net/u/2346786/blog/480410