首页 > 代码库 > Properties & Method
Properties & Method
【Properties】
1、lazy property,通过@property来定义, lazy property的属性直到使用的时候才初始化:
2、Computed Properties:
2、对于set方法,如果没有定义参数,则参数默认为newValue:
3、通过去除set方法,以及去除get关键字,即可定义一个readonly属性:
4、observers:
5、定义Type Property:
【Method】
1、可以通过self来引用内部变量。
2、mutating修饰的方法可以修改变量:
3、mutating方法中给self赋值:
4、定义Type Method:
在Type Method中,self指向type本身。
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。