//
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