Initialize and load two class methods in iOS simple comprehension

Source: Internet
Author: User

If you rewrite these two class methods in a Uiviewcontroller, you will find a phenomenon in this controller:

1, in the same place:

(1) These two class methods are called before Init.

(2) No matter how many times you use this class in the app, the two class methods will only be called once

2, differences:

(1) load is called before initialize

(2) More specifically, if you do not use the controller you have rewritten. The load class method that you override will also be called. In other words, the load method was called before the Didfinishlaunchingwithoptions method. Magic

3, Usage: Load class method, song not used. Just used the Initialize class method. So ...

A golden application of the Initialize class method:

Often in an app, the navigation bar controller's navigation bars are almost uniform. Plus, in general, an app app overrides a navigation controller class. Then the Initialize class method will be able to play. For example:

+ (void) Initialize {

NSLog (@ "%s:%s", __file__,__func__);

Set the navigation bar theme

Uinavigationbar *navbar = [Uinavigationbar appearance];

Next, you can take the navbar to sit on a variety of unified settings processing. For example, font, background ....

}

Dear God, if this blog is inappropriate, hope to ask QQ:771722918.

Initialize and load two class methods in iOS simple comprehension

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.