美文网首页
@property修饰符

@property修饰符

作者: Sunday_David | 来源:发表于2018-03-20 10:47 被阅读0次
    本小节知识:
    1. 【掌握】@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开头

    相关文章

      网友评论

          本文标题:@property修饰符

          本文链接:https://www.haomeiwen.com/subject/zuuvqftx.html