#import <Foundation/Foundation.h>
@class AnotherClass;
@interface TestClass : NSObject {
int age;
NSString *name;
}
-(void) doMethod1;
-(void) doMethod3: (NsString *)str withAnotherPara:(float) value;
+(void) doMethod4;
-(void) doMethod2: (NSString *)str;
@end
方法实现示例:
#import “TestClass.h”
@implementation TestClass
-(void) doMethod1{
--(方法主体)--
}
-(void) doMethod2:(NSString *) str{
--(方法主体)--
}
-(void) doMethod3:(NSString *) str withAnotherPara:(float) value {
--(方法主体)--
}
+(void) doMethod4 {
--(方法主体)--
}
调用方法示例:
TestClass *justTest =[TestClass alloc];
[justTest doMethod1];
[justTest doMethod2 : @”Holle Xiaming”];
[justTest doMethod3 : @”Holle xiaming”withAnotherPara:1.0f];
//类方法可直接使用类名调用//
[TestClass doMethod4];
【云广告】:
本文章由网友发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!