/**load * When a class is loaded into the OC Runtime (memory), it is called once *//**initialize * * When the class is first used
#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]; } output result 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--------------
Initialize and load