The nature of the class

Source: Internet
Author: User

//

Main.m

06-Nature of the class

//

Created by Apple on 13-8-8.

Copyright (c) 2013 itcast. All rights reserved.

//

#import <Foundation/Foundation.h>

#import "Person.h"

#import "Student.h"

#import "GoodStudent.h"

/*

1. When the program starts, all classes and classifications in the project are loaded, and the +load method for each class and classification is called after it is loaded. will only be called once.

2. When a class is used for the first time, the +initialize method of the current class is called

3. Load the parent class first, then load the subclass (call the +load method of the parent class first, and then call the +load method of the subclass)

Initializes the parent class first, initializes the subclass (invokes the +initialize method of the parent class, and then calls the +initialize method of the subclass)

*/

int main ()

{

[[Goodstudent alloc] init];

return 0;

}

void Test1 ()

{

Person *p = [[Person alloc] init];

[Person Test];

In-Memory class objects

Class object = = Class

Class C = [P class];

[C Test];

Person *P2 = [[C new] init];

NSLog (@ "00000");

}

void Test ()

{

Use the person class to create an object of 2 person types

Person *p = [[Person alloc] init];

Person *P2 = [[Person alloc] init];

Person *P3 = [[Person alloc] init];

Get the class object in memory

Class C = [P class];

Class C2 = [P2 class];

Get the class object in memory

Class C3 = [Person class];

NSLog (@ "c=%p, c2=%p, c3=%p", C, C2, C3);

The class itself is also an object, a class-type object, or a class object

/*

Create a person class object with class

Create an object of person type with the person class object

*/

}

The nature of the 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.