1, the object's storage details,
1. When creating an object: Person *p1 = [person new], do three things:
1, application heap memory space;
2, initialize the instance variables;
3, return the first address of the application space;
2. Instance variables are saved in the heap area
3. Object methods are saved in the code area
4. A class can create multiple objects;
2, #pragma mark Directive,
Features: grouping code to facilitate code discovery and navigation
Use format: #pragma mark-
#waring a feature that waits to be processed, or a feature that is not completed
3, the difference between the function and the object method,
I. Object methods:
-(void) run;
(1) The implementation of the object method in @[email protected]
The declaration of an object method can only be written in the middle of @[email protected]
(2) Object methods begin with a-number
(3) Object methods can only be called by objects
(4) The function belongs to the entire file, can be written anywhere in the file, including @[email protected], but written in @[email protected] will not be recognized, the function of the declaration can be inside the main function can also be outside the main function.
(5) Object method belongs to object all
Two. Functions:
void Run () {
}
(1) All functions are parallel.
(2) function has no affiliation
(3) The use of the time can be directly called
(4) You cannot access member variables in an object
4, the relationship between the object and the method,
One, the object as the parameter of the method
-(void) Displayperson: (person *) person{
NSLog ("Name:%@", person->name);
}
Two, the return value of the object as a method
-(Person *) Changeperson: (person *) person{
Person->name = @ "Tang's Monk";
return person;
}
5. Classroom Exercises
1, Object storage details, 2, #pragma mark Directive, 3, difference between function and object method, 4, relationship between object and method, 5. Classroom Exercises