zoukankan      html  css  js  c++  java
  • Init & Deinit & ARC

    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的强引用:

      

  • 相关阅读:
    SPOJ AMR12B 720
    OUC_TeamTraining_#1 720
    Mac下安装必须软件
    spawn命令和expect
    python基础
    AndroidManifest.xml详解
    Ubuntu系统连接Android真机调试
    Android Studio 快捷键
    linux 解压/压缩命令
    sadasd
  • 原文地址:https://www.cnblogs.com/tekkaman/p/3791068.html
Copyright © 2011-2022 走看看