iOS development-class loading load function and initialize function
Source: Internet
Author: User
<span id="Label3">Briefly summarize<p>Load is a class-loading method, and initialize is the class initialization method.</p>Points<p>You do not need to call the Super Method.</p><p>The Initialize and load method systems are called only once, and developers can call them multiple times (yes, but not recommended).</p><p><span style="line-height: 1.5;">Class is loaded into the system called the load method, and the class first uses the call initialize Method.</span></p><p><span style="line-height: 1.5;">Initialize and Load methods do not add too much logic, analogy do not do too much in the initialization method.</span></p><p>Global variables that cannot be initialized at compile time can be implemented in initialize, and the swizzling logic can be implemented in the load Method.</p><p><span style="color: #800000;">The call to load is not considered the first method of the class to complete, because the method in the current class is called in load, and the Initialize method is executed First.</span></p><p>The order of the Load method call: the method of the parent class (superclass) takes precedence over subclasses (subclass), and the methods in the class take precedence over the methods in the Category.</p><p><span style="color: #800000;">The Load method in all categories is executed, and the substitution effect of the normal function is Different.</span></p><p>The Initialize method in the last category will overwrite the Initialize method in the previous category and class.</p><p>Study Questions</p><p>1, there is Class A inheritance class p, Class B bearing class p, then the load method of the three classes, the Initialize method of the invocation sequence is how to decide?</p><p></p><p>2, there is class a, there is Class A category C1, there is Class A category C2, if a, C1, C2 all implemented load, the order of the invocation is how to decide?</p><p></p><p>Reference</p><p>The call before the Iosmain function</p><p>Load and Initialize functions</p><p>iOS development-class loading load function and initialize function</p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service