Objective-c 类实现 (@implementation)
2015-11-13 18:04
369 查看
在用@interface声明类之后,可以使用@implementation进行实类的实现。类的实现的具体语法如下:
[cpp] view plaincopy
@implementation 类名
方法实现代码;
@end;
实例:
[cpp] view plaincopy
@implementation Person
- (NSString*) name {
return name;
}
- (int) age {
return age;
}
- (void) setName: (NSString*) input {
name = input;
}
- (void) setAge: (int) input {
age = input;
}
@end;
类的实现代码以@implementation开始,以@end结束。
这部分代码通常都是放在.m文件中。
[cpp] view plaincopy
@implementation 类名
方法实现代码;
@end;
实例:
[cpp] view plaincopy
@implementation Person
- (NSString*) name {
return name;
}
- (int) age {
return age;
}
- (void) setName: (NSString*) input {
name = input;
}
- (void) setAge: (int) input {
age = input;
}
@end;
类的实现代码以@implementation开始,以@end结束。
这部分代码通常都是放在.m文件中。
相关文章推荐
- Objective-c 类接口 (@interface) (类定义)
- Objective-c 程序结构
- Objective-c中@interface、@implementation、@protocal
- Objective-C之Meta-class和isa指针
- 关于 error: Operation is not valid due to the current state of the object。
- Object-C 字符串类各种操作方法
- Objective-C 笔记一(HelloWorld)
- Qt中的Q_OBJECT
- iOS UIWebView中javascript与Objective-C交互、获取摄像头
- iOS开发-object-c之 @[], @{}
- Object-C 自学笔记 - 1
- 详解Objective-C中委托和协议
- Class-Specific Hough Forests for Object Detection
- Object.create函数
- 自动化测试---PageObjects快速入门(一)
- Qt出现QObject::connect: Cannot queue arguments of type '******'的解决方法
- org.objectweb.asm.ClassVisitor.visit(转载)
- Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法
- Objective C类方法load和initialize的区别
- ajax获取的全部是object,我要获取的是json