Swift defines two kinds of initializers for class types to help ensure all stored properties receive an initial value. These are known as designated initializers and convenience initializers.

Designated:指定的;特指的

全初始化与部分初始化

Designated Initializers and Convenience Initializers

Designated initializers are the primary initializers for a class. A designated initializer fully initializes all properties introduced by that class and calls an appropriate superclass initializer to continue the initialization process up the superclass chain.

Convenience initializers are secondary, supporting initializers for a class. You can define a convenience initializer to call a designated initializer from the same class as the convenience initializer with some of the designated initializer’s parameters set to default values.

swift语言点评十七-Designated Initializers and Convenience Initializers的更多相关文章

  1. swift语言点评四-Closure

    总结:整个Closure的作用在于简化语言表述形式. 一.闭包的简化 Closure expression syntax has the following general form: { () -& ...

  2. swift语言点评二

    一.数据类型 1.基础类型的封装 Swift provides its own versions of all fundamental C and Objective-C types, includi ...

  3. swift语言点评十九-类型转化与检查

    1.oc比较: -(BOOL) isKindOfClass: classObj判断是否是这个类或者这个类的子类的实例 -(BOOL) isMemberOfClass: classObj 判断是否是这个 ...

  4. swift语言点评十八-异常与错误

    1.错误类型与枚举的结合 enum VendingMachineError: Error { case invalidSelection case insufficientFunds(coinsNee ...

  5. swift语言点评十六-Initialization && Deinitialization

    initial value:必须初始化.不影响观察者 Classes and structures must set all of their stored properties to an appr ...

  6. swift语言点评十四-继承

    Overriding A subclass can provide its own custom implementation of an instance method, type method, ...

  7. swift语言点评十-Value and Reference Types

    结论:value是拷贝,Reference是引用 Value and Reference Types Types in Swift fall into one of two categories: f ...

  8. swift语言点评八-枚举

    总结:swift中的枚举可以看作变量可以作为case匹配参数的类 Enumerations 枚举的作用:状态列举与匹配 枚举值与类型 If a value (known as a “raw” valu ...

  9. swift语言点评五-Function

    一.函数类型 Every function in Swift has a type, consisting of the function’s parameter types and return t ...

随机推荐

  1. 洛谷P4014 分配问题(费用流)

    题目描述 有 nn 件工作要分配给 nn 个人做.第 ii 个人做第 jj 件工作产生的效益为 c_{ij}cij​ .试设计一个将 nn 件工作分配给 nn 个人做的分配方案,使产生的总效益最大. ...

  2. Eclipse中删除GIT分支

    删除GIT分支: 删除分支时不能直接删除本分支,所以要切换到另一分支,即非删除分支. 1.右击项目——Team——Advanced——Delete Branch...: 2. 在弹出的Delete b ...

  3. CSS骚操作

    获取当前HTML页面根元素的字体大小 getComputedStyle(document.getElementsByTagName("html")[0],undefined).fo ...

  4. docker mysql pxc集群(percona-xtradb-cluster)

    docker pull percona/percona-xtradb-cluster docker tag percona/percona-xtradb-cluster pxc docker netw ...

  5. Centos 6/7 忘记root密码处理方法

    1. centos 6.x 重置root密码 开机按esc  到下图 按 e 键进入编辑模式,通常选择第二项后按 e 键编辑此项 进入该编辑模式后,在quiet后面输入 simple 或者 1 然后回 ...

  6. myeclipse反编译安装 jd-gui.exe下载

    一:在线安装 1.Help->Install New Site Name:** Location:http://jd.benow.ca/jd-eclipse/update 二:手动安装 1.下载 ...

  7. JAVA 重载方法,参数为NULL时,调用的处理 (精确性原则)

    引子:大家可以思考一下下面程序的输出结果 public class TestNull { public void show(String a){ System.out.println("St ...

  8. vue实现双向绑定原理

  9. tomcat的连接数与线程池

    在使用tomcat时,经常会遇到连接数.线程数之类的配置问题,要真正理解这些概念,必须先了解Tomcat的连接器(Connector). 在前面的文章中写到过:Connector的主要功能,是接收连接 ...

  10. http响应的封装

    响应的封装: 资源的初始化 分析请求响应信息,根据状态响应码,发送不同的状态码 浏览器根据状态信息,做出不同的执行 构建正文,也就是根据浏览器客服端的请求发送响应信息: 发送响应:code 是状态码, ...