diff --git a/source/chapter1/01_swift.md b/source/chapter1/01_swift.md index 41859503..f87e6dff 100644 --- a/source/chapter1/01_swift.md +++ b/source/chapter1/01_swift.md @@ -1,4 +1,5 @@ # 关于 Swift +----------------- Swift 是一种新的编程语言,用于编写 iOS 和 OS X 应用。Swift 结合了 C 和 Objective-C 的优点并且不受C的兼容性的限制。Swift 使用安全的编程模式并添加了很多新特性,这将使编程更简单,扩展性更强,也更有趣。除此之外,Swift 还支持人见人爱的 Cocoa 和 Cocoa Touch 框架。拥有了这些特性,Swift将重新定义软件开发。 diff --git a/source/chapter1/02_a_swift_tour.md b/source/chapter1/02_a_swift_tour.md index 4246f4ee..6cdbf500 100644 --- a/source/chapter1/02_a_swift_tour.md +++ b/source/chapter1/02_a_swift_tour.md @@ -1,4 +1,5 @@ # Swift 初见 +----------------- 本页内容包括: diff --git a/source/chapter2/01_The_Basics.md b/source/chapter2/01_The_Basics.md index af727cb0..1a65cb85 100644 --- a/source/chapter2/01_The_Basics.md +++ b/source/chapter2/01_The_Basics.md @@ -1,4 +1,5 @@ # 基础部分 +----------------- Swift 是 iOS 和 OS X 应用开发的一门新语言。然而,如果你有 C 或者 Objective-C 开发经验的话,你会发现 Swift 的很多内容都是你熟悉的。 diff --git a/source/chapter2/02_Basic_Operators.md b/source/chapter2/02_Basic_Operators.md index 236736a1..3ad88bbb 100644 --- a/source/chapter2/02_Basic_Operators.md +++ b/source/chapter2/02_Basic_Operators.md @@ -1,4 +1,5 @@ # 基本运算符 +----------------- 运算符是检查, 改变, 合并值的特殊符号或短语. 例如, 加号 `+` 把计算两个数的和(如 `let i = 1 + 2`). 复杂些的运行算包括逻辑与`&&`(如 `if enteredDoorCode && passedRetinaScan`), 还有自增运算符 `++i` 这样让自身加一的便捷运算. diff --git a/source/chapter2/03_Strings_and_Characters.md b/source/chapter2/03_Strings_and_Characters.md index 01f02c3a..5c249ed8 100644 --- a/source/chapter2/03_Strings_and_Characters.md +++ b/source/chapter2/03_Strings_and_Characters.md @@ -1,6 +1,5 @@ # 字符串和字符 (Strings and Characters) - ----- +----------------- 本页包含内容: diff --git a/source/chapter2/04_Collection_Types.md b/source/chapter2/04_Collection_Types.md index be08a5af..6a1be08e 100644 --- a/source/chapter2/04_Collection_Types.md +++ b/source/chapter2/04_Collection_Types.md @@ -1,4 +1,5 @@ # 集合类型 (Collection Types) +----------------- Swift语言提供经典的数组和字典两种集合类型来存储集合数据。数组用来按顺序存储相同类型的数据。字典虽然无序存储相同类型数据值但是需要由独有的标识符引用和寻址(就是键值对)。 diff --git a/source/chapter2/05_Control_Flow.md b/source/chapter2/05_Control_Flow.md index ba2fbb9f..2ced399a 100644 --- a/source/chapter2/05_Control_Flow.md +++ b/source/chapter2/05_Control_Flow.md @@ -1,4 +1,5 @@ -#控制流 +# 控制流 +----------------- Swift提供了类似C语言的流程控制结构,包括可以多次执行任务的`for`和`while`循环,基于特定条件选择执行不同代码分支的`if`和`switch`语句,还有控制流程跳转到其他代码的`break`和`continue`语句。 diff --git a/source/chapter2/06_Functions.md b/source/chapter2/06_Functions.md index 3bd3cc2a..f66c668c 100644 --- a/source/chapter2/06_Functions.md +++ b/source/chapter2/06_Functions.md @@ -1,4 +1,5 @@ # 函数(Functions) +----------------- 本页包含内容: diff --git a/source/chapter2/07_Closures.md b/source/chapter2/07_Closures.md index 2f4b16ff..8cce8708 100644 --- a/source/chapter2/07_Closures.md +++ b/source/chapter2/07_Closures.md @@ -1,6 +1,5 @@ # 闭包 - ----- +----------------- 本页内容包含: diff --git a/source/chapter2/08_Enumerations.md b/source/chapter2/08_Enumerations.md index 5fb758a8..c80ae4be 100644 --- a/source/chapter2/08_Enumerations.md +++ b/source/chapter2/08_Enumerations.md @@ -1,4 +1,5 @@ # 枚举 +----------------- 本页内容包含: diff --git a/source/chapter2/11_Methods.md b/source/chapter2/11_Methods.md index 3c5a6013..d090d756 100644 --- a/source/chapter2/11_Methods.md +++ b/source/chapter2/11_Methods.md @@ -1,4 +1,5 @@ -# 方法(Methods) +# 方法(Methods) +----------------- **方法**是与某些特定类型相关联的函数。类、结构体、枚举都可以定义实例方法;实例方法为给定类型的实例封装了具体的任务与功能。类、结构体、枚举也可以定义类型方法;类型方法与类型自身相关联。类型方法与Objective-C中的类方法(class methods)相似。 diff --git a/source/chapter2/12_Subscripts.md b/source/chapter2/12_Subscripts.md index 078d7e0b..f35bc5d7 100644 --- a/source/chapter2/12_Subscripts.md +++ b/source/chapter2/12_Subscripts.md @@ -1,4 +1,5 @@ -# 下标 (Subscripts) +# 下标(Subscripts) +----------------- 下标可以定义在类(Class)、结构体(structures)和枚举(enumerations)这些目标中,可以认为是访问对象、集合或序列的快捷方式。举例来说,用下标访问一个数组(Array)实例中的元素可以这样写 `someArray[index]` ,访问字典(Dictionary)实例中的元素可以这样写 `someDictionary[key]`,而不需要再调用实例的某个方法来获得元素的值。 diff --git a/source/chapter2/13_Inheritance.md b/source/chapter2/13_Inheritance.md index 7532056f..11b3371e 100644 --- a/source/chapter2/13_Inheritance.md +++ b/source/chapter2/13_Inheritance.md @@ -1,4 +1,5 @@ # 继承 +----------------- 一个类可以继承另一个类的方法,属性和其它特性。当一个类继承其它类,继承类叫子类,被继承类叫超类(或父类)。在Swift中,继承是区分「类」与其它类型的一个基本特征。 diff --git a/source/chapter2/15_Deinitialization.md b/source/chapter2/15_Deinitialization.md index 796ea4c9..939b2d12 100644 --- a/source/chapter2/15_Deinitialization.md +++ b/source/chapter2/15_Deinitialization.md @@ -1,4 +1,5 @@ -#析构过程 +# 析构过程 +----------------- 在一个类的实例被释放之前,析构函数被立即调用。用关键字deinit来标示析构函数,类似于初始化函数用init来标示。析构函数只适用于类类型。 diff --git a/source/chapter2/16_Automatic_Reference_Counting.md b/source/chapter2/16_Automatic_Reference_Counting.md index 9611913c..603fc1f7 100644 --- a/source/chapter2/16_Automatic_Reference_Counting.md +++ b/source/chapter2/16_Automatic_Reference_Counting.md @@ -1,4 +1,5 @@ # 自动引用计数 +----------------- 本页包含内容: diff --git a/source/chapter2/17_Optional_Chaining.md b/source/chapter2/17_Optional_Chaining.md index 1fc7100b..d3cd61d3 100644 --- a/source/chapter2/17_Optional_Chaining.md +++ b/source/chapter2/17_Optional_Chaining.md @@ -1,4 +1,5 @@ -#Optional Chaining +# Optional Chaining +----------------- 可选链(Optional Chaining)是一种可以请求和调用属性、方法及子脚本的过程,它的自判断性体现于请求或调用的目标当前可能为空(`nil`)。如果自判断的目标有值,那么调用就会成功;相反,如果选择的目标为空(`nil`),则这种调用将返回空(`nil`)。多次请求或调用可以被链接在一起形成一个链,如果任何一个节点为空(`nil`)将导致整个链失效。 diff --git a/source/chapter2/18_Type_Casting.md b/source/chapter2/18_Type_Casting.md index b93c45fe..737eb681 100644 --- a/source/chapter2/18_Type_Casting.md +++ b/source/chapter2/18_Type_Casting.md @@ -1,4 +1,5 @@ -#类型检查(Type Casting) +# 类型检查(Type Casting) +----------------- (ps:为了方便各位检验所以保留了英文,可删。) _类型检查_是一种检查类实例的方式,并且哦或者也是让实例作为它的父类或者子类的一种方式。 diff --git a/source/chapter2/19_Nested_Types.md b/source/chapter2/19_Nested_Types.md index 900bc940..b25c35ae 100644 --- a/source/chapter2/19_Nested_Types.md +++ b/source/chapter2/19_Nested_Types.md @@ -1,4 +1,5 @@ -#类型嵌套 +# 类型嵌套 +----------------- 本页包含内容: diff --git a/source/chapter2/21_Protocols.md b/source/chapter2/21_Protocols.md index 018c8efe..a0dd63c1 100644 --- a/source/chapter2/21_Protocols.md +++ b/source/chapter2/21_Protocols.md @@ -1,4 +1,5 @@ # 协议 +----------------- `Protocol(协议)`用于**统一**方法和属性的名称,而不实现任何功能,(*译者注: 协议在其他语言中也称作`接口(Interface)`*).`协议`能够被`类`,`枚举`,`结构体`实现,满足协议要求的`类`,`枚举`,`结构体`被称为协议的`遵循者`. diff --git a/source/chapter3/01_About_the_Language_Reference.md b/source/chapter3/01_About_the_Language_Reference.md index f17b2a94..a537578c 100644 --- a/source/chapter3/01_About_the_Language_Reference.md +++ b/source/chapter3/01_About_the_Language_Reference.md @@ -1,4 +1,5 @@ # 关于语言附注 +----------------- 本书的这一节描述了Swift编程语言的形式语法。这里描述的语法是为了帮助您更详细的了解该语言,而不是让您直接实现一个解析器或编译器。 diff --git a/source/chapter3/02_Lexical_Structure.md b/source/chapter3/02_Lexical_Structure.md index 625c0a4a..0ab9eee4 100644 --- a/source/chapter3/02_Lexical_Structure.md +++ b/source/chapter3/02_Lexical_Structure.md @@ -1,4 +1,5 @@ # 语法结构 +----------------- 本页包含内容: diff --git a/source/chapter3/03_Types.md b/source/chapter3/03_Types.md index b031e17f..51827579 100644 --- a/source/chapter3/03_Types.md +++ b/source/chapter3/03_Types.md @@ -1,6 +1,5 @@ # 类型(Types) - ---- +----------------- 本页包含内容: diff --git a/source/chapter3/04_Expressions.md b/source/chapter3/04_Expressions.md index d045418d..9ba92787 100644 --- a/source/chapter3/04_Expressions.md +++ b/source/chapter3/04_Expressions.md @@ -1,6 +1,5 @@ # 表达式(Expressions) - ---- +----------------- Swift 中存在四种表达式: 前缀(prefix)表达式,二元(binary)表达式,主要(primary)表达式和后缀(postfix)表达式。表达式可以返回一个值,以及运行某些逻辑(causes a side effect)。 diff --git a/source/chapter3/06_Attributes.md b/source/chapter3/06_Attributes.md index 657a22d0..248c0276 100644 --- a/source/chapter3/06_Attributes.md +++ b/source/chapter3/06_Attributes.md @@ -1,4 +1,5 @@ # 特性 +----------------- 特性提供了关于声明和类型的更多信息。在Swift中有两类特性,用于修饰声明的以及用于修饰类型的。例如,`required`特性,当应用于一个类的指定或便利初始化器声明时,表明它的每个子类都必须实现那个初始化器。再比如`noreturn`特性,当应用于函数或方法类型时,表明该函数或方法不会返回到它的调用者。 diff --git a/source/chapter3/07_Patterns.md b/source/chapter3/07_Patterns.md index c0344576..9efceedd 100644 --- a/source/chapter3/07_Patterns.md +++ b/source/chapter3/07_Patterns.md @@ -1,4 +1,5 @@ # 模式(Patterns) +----------------- 模式(pattern)代表了单个值或者复合值的结构。例如,元组`(1, 2)`的结构是逗号分隔的,包含两个元素的列表。因为模式代表一种值的结构,而不是特定的某个值,你可以把模式和各种同类型的值匹配起来。比如,`(x, y)`可以匹配元组`(1, 2)`,以及任何含两个元素的元组。除了将模式与一个值匹配外,你可以从合成值中提取出部分或全部,然后分别把各个部分和一个常量或变量绑定起来。 diff --git a/source/chapter3/09_Summary_of_the_Grammar.md b/source/chapter3/09_Summary_of_the_Grammar.md index 37d5c214..339b6f2c 100644 --- a/source/chapter3/09_Summary_of_the_Grammar.md +++ b/source/chapter3/09_Summary_of_the_Grammar.md @@ -1,15 +1,16 @@ # 语法总结 +----------------- 本页包含内容: -* 语句(Statements) -* 泛型参数(Generic Parameters and Arguments) -* 声明(Declarations) -* 模式(Patterns) -* 特性(Attributes) -* 表达式(Expressions) -* 词法结构(Lexical Structure) -* 类型(Types) +* [语句(Statements)](#label1) +* [泛型参数(Generic Parameters and Arguments)](#label2) +* [声明(Declarations)](#label3) +* [模式(Patterns)](#label4) +* [特性(Attributes)](#label5) +* [表达式(Expressions)](#label6) +* [词法结构(Lexical Structure)](#label7) +* [类型(Types)](#label8) ## 语句 diff --git a/source/chapter3/10_Statements.md b/source/chapter3/10_Statements.md index 3f603590..60e5ed42 100644 --- a/source/chapter3/10_Statements.md +++ b/source/chapter3/10_Statements.md @@ -1,4 +1,5 @@ # 语句 +----------------- 在 Swift 中,有两种类型的语句:简单语句和控制流语句。简单语句是最常见的,用于构造表达式和声明。控制流语句则用于控制程序执行的流程,Swift 中有三种类型的控制流语句:循环语句、分支语句和控制传递语句。