1. Code Description:
 
Person. h
 
   
Person. h
 
 
# Import 
 
@ Interface Person: NSObject
 
{
 
Int age, sex; // variable definition
 
Int height, width;
 
}
 
@ Property int age, sex; // attribute Definition
 
@ Property char height;
 
//-(Void) setAge;
 
-(Int) setAge1 :( int);
 
-(Int) setWH :( int) w :( int) h;
 
/* Method definition
 
Format
 
-(Returned data type) method name: (Data Type of parameter 1) parameter 1 Name: (Data Type of parameter 2) parameter 2 Name
 
*/
 
@ End
 
Person. m
 
   
Person. m
 
 
# Import "Person. h"
 
@ Implementation Person
 
@ Synthesize age, sex; // accessors
 
// @ Synthesize height;
 
/*
 
My annotations]
 
@ Synthesize reference @ property Association @ interface
 
If no reference or association is found, an error is thrown.
 
*/
 
# Pragma mark ------ setAge ----
 
//-(Void) setAge;
 
//{
 
// Age = 20;
 
//}
 
# Pragma mark ------ setAge1 ------
 
-(Int) setAge1 :( int)
 
{
 
Age =;
 
Return age;
 
}
 
# Pragma mark ------ setWH ------
 
-(Int) setWH :( int) w :( int) h // method implementation
 
{
 
Length = 100;
 
Height = 175;
 
Return age * height;
 
}
 
@ End
 
Main. m
 
   
Main. m
 
 
# Import 
 
# Import "Person. h"
 
Int main (int argc, const char * argv [])
 
{
 
@ Autoreleasepool {
 
Person * person = [Person alloc];
 
[Person init];
 
Person. age = 1; // attribute
 
NSLog (@ "person. ag = % I", person. age); // output attributes. Pay attention to type Matching. Otherwise, an error is thrown.
 
NSLog (@ "person = % @", person); // output object
 
[Person setWH: 6: 10]; // Method
 
[Person release]; // If the ARC mechanism is used, release cannot be used.
 
}
 
Return 0;
 
}
 
2. My annotations (see the following three figures ):
 
@ Synthesize reference @ property Association @ interface
 
If no reference or association is found, an error is thrown.