Init & Deinit & ARC
摘要:【Init & Deinit】1、switf中,init不返回值,只负责初始化成员变量。在init方法中可以初始化常量。 2、默认初始化。 3、Swift provides an automatic external name for every parameter in an initiali...
阅读全文
Subscript & Inheritance
摘要:【Subscript】1、subscript的定义: 2、Subscript的使用: 3、可以定义多维subscript: 多维Subscript的使用: 【Inheritance】1、override property: 2、overriding property observe...
阅读全文
Properties & Method
摘要:【Properties】1、lazy property,通过@property来定义, lazy property的属性直到使用的时候才初始化: 2、Computed Properties: 2、对于set方法,如果没有定义参数,则参数默认为newValue: 3、通过去除set方法,以及去...
阅读全文
Enumeration & Class & Structure
摘要:【Enumeration】1、当一个枚举值类型已经确定后,可以使用shorter dot syntax来赋予其它值: 2、对一个枚举值switch的时候也可以使用short dot syntax: 3、Associate Value 定义: 上面extract的值均为const,把...
阅读全文
Functions & Closures
摘要:【Functions】1、不带返回值的函数: 2、通过tuple返回元素 返回的tuple可按如下方式使用: 3、External Parameter: External parameter的使用: 4、Shorthand external parameter: 5、Defa...
阅读全文
Control Flow
摘要:【Control Flow】1、for loop中的元素可以省略: 2、for initializer中的变量只能在循环内使用。3、if、else if、else的用法: 最后一个else可选。4、switch用法: 5、range match: 6、tuple作为case: 7、va...
阅读全文
Collection Types
摘要:【Collection Types】1、Arrays store ordered lists of values of the same type. Value必须是同一类型。2、Array的原型是Array。也可写成someType[]的形式。3、使用count属性来返回Array中的元素个数。 ...
阅读全文
Basics
摘要:【Basics】1、You can declare multiple constants or multiple variables on a single line, separated by commas: 2、You can use almost any character you like...
阅读全文
Enumeration & Structures & Protocl & Extension
摘要:【Enumeration and Structures】1、使用toRaw、fromRaw方法可以在原始值之间。注意enum的定义中使用了case。另外要注意switch中的枚举值。 2、struct和class最大的区别在于,struct被传递时,使用的是使用的是copy。 3、枚举变量可以有...
阅读全文
Objects & Class
摘要:【Objects & Class】1、定义一个类。 上述代码中,numberOfSides是实例变量,simpleDescription也是实例方法。2、创建实例,使用实例。 3、init是构造函数,deinit是析构函数: 上图代码中使用self来引用成员变量是为了与局部变量name...
阅读全文
变量&流程控制&函数
摘要:【Swift初步】1、第一个swift程序。 You don’t need to import a separate library for functionality like input/output or string handling. Code written at global s...
阅读全文