@property修饰符

@property修饰符

  • 修饰是否生成getter方法的
    • readonly 只生成setter方法,不生成getter方法
    • readwrite 既生成getter 又生成setter方法(默认)
@property (readonly) int age;
  • 指定所生成的方法的方法名称
  1. getter=你定制的getter方法名称
  2. setter=你定义的setter方法名称(注意setter方法必须要有 :)
@property (getter=isMarried)  BOOL  married;
说明,通常BOOL类型的属性的getter方法要以is开头
原文地址:https://www.cnblogs.com/xufengyuan/p/6575405.html