黑马程序员技术交流社区
标题: oc关键字 [打印本页]
作者: sc33370 时间: 2016-6-22 19:01
标题: oc关键字
(一)@property 关键字
@property 关键字可以自动生成某个成员变量的setter和getter方法的声明
@property int age;
编译时遇到这一行,则自动扩展成下面两句:
- (void)setAge:(int)age;
- (int)age;
(二)@synthesize关键字
@synthesize关键字帮助生成成员变量的setter和getter方法的实现。
语法:@synthesize age=_age;
相当于下面的代码:
- (void)setAge:(int)age
{
_age=age;
}
- (int)age
{
Return _age;
}
作者: lijunyusmile 时间: 2016-7-8 22:19
不错哦~~~~~~~~~
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) |
黑马程序员IT技术论坛 X3.2 |