Synchronous push-face test-ios simple comprehension of the essence of class

Source: Internet
Author: User

1. Class is also an object

      • Class is an object of type class object
      • Definition of class type
    1. An arbitrary type that represents a Objective-c class
    2. typedef struct Objc_class *class;
    • The class name represents the class object, and each class has only one class object
    • Get Class object
    1. Get class objects two ways Person1 and Person2
    2. Class Person1 = [Person class];
    3. Person *p = [person new];
    4. Class Person2 = [P class];
    5. //Class object call class method
    6. Person *person3 = [Person1 new];

2. Loading methods and initialization methods for classes

    1. + (void) load; //called once when the class is loaded
    2. + (void) initialize; //Call once when using a class

+load Method:

    • All classes and classifications are loaded when the program starts, and the +load method for all classes and classifications is automatically invoked
    • The program starts by loading the parent class and then the subclass, that is, calling the +load method of the parent class before calling the +load method of the subclass
    • Load the original class and reload the taxonomy first
    • Regardless of whether the program is running with this class, +load is called to load

+initialize Method:

    • The first time a class is used, such as creating an object, the +initialize method is called once
    • A class invokes the +initialize method only once, calling the parent class before calling the Initialize method of the subclass

Synchronous push-face test-ios simple comprehension of the essence of class

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.