Http://www.cnblogs.com/zhangweia/archive/2011/11/01/2231549.html
1. The document is divided into . h: Defines the interface, its properties, and the method description. . M: is the implementation class.
2, the user's class is generally derived from NSObject, the class name is capitalized, the instance name is lowercase.
3. attributes : Defined within interface, modifier, @priavte, @protected (default), @public
4, method : Define the former "-" represents the instance method, "+" represents the class method.
5, The type is to add ().
--------------------------------------------------------------------------------------
1.
Format of the header file:
#import <Foundation/Foundation.h>
@interface Myclass:nsobject
{
int numerator;
int denominator;
}
-(void) print;
-(void) Setnumberator: (int) n;
-(void) Setdenominator: (int) D;
@end
The format implemented by the class:
#import "Myclass.h"
@implementation MyClass
-(void) print
{
NSLog (@ "Hello zwh!");
NSLog (@ "%i/%i", numerator,denominator);
}
-(void) Setnumberator: (int) n
{
Numerator = n;
}
-(void) Setdenominator: (int) d
{
denominator = D;
}
@end
Object-c-Definition of class