【Init & Deinit】
1、switf中,init不返回值,只负责初始化成员变量。在init方法中可以初始化常量。
2、默认初始化。
3、Swift provides an automatic external name for every parameter in an initializer if you don’t provide an external name yourself.
4、structure types automatically receive a memberwise initializer if they provide default values for all of their stored properties and do not define any of their own custom initializers.
5、Note that if you define a custom initializer for a value type, you will no longer have access to the default initializer (or the memberwise structure initializer, if it is a structure) for that type.
6、指定的初始化构造函数规则:
7、定义convenience initializer:
8、如果本类没有定义任何designated initializer,compiler会自动为本类生成一个designated initializer,此initializer会继承父类的的designated initilizer。
9、通过Closure设置初始值。
【ARC】
1、使用weak变量来解除强引用环:
2、使用unowned变量来解除强引用:
3、通过Capture List来破除Closure与self的强引用: