These days and carefully looked at the company's SDK, the previous load, initialize and blurred again, and then ...
YY after still want to do some work to do something ~ t_t ~
+ (void) initialize, + (void) load is the two class method of NSObject, and NSObject as a powerful root class,
Provides a series of life cycle, threading, introspection, runtime, archive, and other methods for other classes. As the Root class has also been
Very capable.
What difference does it have, and how to use it?
1. Load is called whenever a file of the class is referenced, and initialize is called before the first method of the class or its subclasses is called.
So if the class is not referenced into the project, there will be no load call, but even if the class file is referenced but not used, then
Initialize will not be called. There's a lot of crap.
2, +initialize will only be called once, the category of the +initialize method will override the +initialize method of the class itself, and in the category
The +load method does not overwrite the +load method in its own class. If the +initialize method is implemented in the parent class, and the child class does not override this
method, the parent class's method ([Super Initialize]) is used when the subclass is initialized. Of course you don't want to call the initialization method of the parent class, also
Can be rewritten, the code is as follows
+ (void) Initialize { if (self = = [ClassName self]) { //...} Do the initialization ... }
3. Usage Scenarios
The changes to the category are placed in the intialize in the load.
Official explanation:
Verification code and analysis see: http://wufawei.com/2013/06/load-initialize/
If you feel that the above is simple enough, just look at this article.
Http://www.cnblogs.com/ider/archive/2012/09/29/objective_c_load_vs_initialize.html
If you look at the dazzling, English can also look at the foreigner to write this article
Https://mikeash.com/pyblog/friday-qa-2009-05-22-objective-c-class-loading-and-initialization.html
[IOS] Initialize VS load Wars 3k round.