property

@property 数据类型 属性名(去掉下划线);

@property int age;

如果此时加了下划线@property int _age;则相当于给双下划线属性赋值__age

 

设置读写属性

@property (readonly) int age;//只读(只有get没有set方法)

@property (readwrite) int age;//读写,默认值

 

指定get/set方法名

@property (setter=abc:) int age;==>-(void) setAbc(int age){...}

@property (getter=abc) int age;==>-(void) getAbc(){...}

get方法重命名用的比较多,用于读取BOOL值

property (getter=isSucess) BOOL sucess;

posted @ 2016-01-12 19:27  爱上咖啡的唐  阅读(268)  评论(0编辑  收藏  举报