本小节知识:
- 【掌握】@property修饰符
1.@property修饰符
- 修饰是否生成getter方法的
- readonly 只生成getter方法,不生成setter方法
- readwrite 既生成getter 又生成setter方法(默认)
@property (readonly) int age;
- 指定所生成的方法的方法名称
- getter=你定制的getter方法名称
- setter=你定义的setter方法名称(注意setter方法必须要有 :)
@property (getter=isMarried) BOOL married;
说明,通常BOOL类型的属性的getter方法要以is开头