新版书籍翻译准备工作

This commit is contained in:
BigNerdCoding
2018-10-14 12:19:39 +08:00
parent 514e7be186
commit 06e5383739
34 changed files with 738 additions and 1158 deletions

174
README.md
View File

@ -17,108 +17,6 @@ Swift 4.2 翻译中,请到 issue 中认领章节。
- 更新到 Swift 3.0。 2016-09-23
# 3.0 译者记录
相关[issue](https://github.com/numbbbbb/the-swift-programming-language-in-chinese/issues/628)
- Functions: [crayygy](https://github.com/crayygy)
- Control Flow: [Realank](https://github.com/Realank)
- Closures: [LanfordCai](https://github.com/LanfordCai)
- Protocols: [chenmingbiao](https://github.com/chenmingbiao)
- The Basics:[chenmingbiao](https://github.com/chenmingbiao)
- Advanced Operators: [mmoaay](https://github.com/mmoaay)
Language Reference:
- Attributes: [WhoJave](https://github.com/WhoJave)
- Statements: [chenmingjia](https://github.com/chenmingjia)
- Declarations: [chenmingjia](https://github.com/chenmingjia)
- Expressions: [chenmingjia](https://github.com/chenmingjia)
- Types: [lettleprince](https://github.com/lettleprince)
- Generic Parameters and Arguments: [chenmingjia](https://github.com/chenmingjia)
# 2.1 & 2.2 译者记录
详见各章节开头位置。
# 2.0 译者记录
- About Swift [xtymichael](https://github.com/xtymichael)
- A Swift Tour[xtymichael](https://github.com/xtymichael)
- The Basics[xtymichael](https://github.com/xtymichael)
- Basic Operators[AlanMelody](https://github.com/AlanMelody)
- Strings and Characters[DianQK](https://github.com/DianQK)
- Collection Types[AlanMelody](https://github.com/AlanMelody)
- Control Flow[AlanMelody](https://github.com/AlanMelody)
- Functions[dreamkidd](https://github.com/dreamkidd)
- Closures[100mango](https://github.com/100mango)
- Enumerations[futantan](https://github.com/futantan)
- Classes and Structures[SkyJean](https://github.com/SkyJean)
- Properties[yangsiy](https://github.com/yangsiy)
- Methods[DianQK](https://github.com/DianQK)
- Subscripts[shanksyang](https://github.com/shanksyang)
- Inheritance[shanksyang](https://github.com/shanksyang)
- Initialization[chenmingbiao](https://github.com/chenmingbiao)
- Deinitialization[chenmingbiao](https://github.com/chenmingbiao)
- Automatic Reference Counting[Channe](https://github.com/Channe)
- Optional Chaining[lyojo](https://github.com/lyojo)
- Error Handling[lyojo](https://github.com/lyojo)
- Type Casting[yangsiy](https://github.com/yangsiy)
- Nested Types[SergioChan](https://github.com/SergioChan)
- Extensions[shanksyang](https://github.com/shanksyang)
- Protocols[futantan](https://github.com/futantan)
- Generics[SergioChan](https://github.com/SergioChan)
- Access Control[mmoaay](https://github.com/mmoaay)
- Advanced Operators[buginux](https://github.com/buginux)
- About the Language Reference[KYawn](https://github.com/KYawn)
- Lexical Structure[buginux](https://github.com/buginux)
- Types[EudeMorgen](https://github.com/EudeMorgen)
- Expressions[EudeMorgen](https://github.com/EudeMorgen)
- Statements[littledogboy](https://github.com/littledogboy)
- Declarations[Lenhoon](https://github.com/Lenhoon)
- Attributes[KYawn](https://github.com/KYawn)
- Patterns[ray16897188](https://github.com/ray16897188)
- Generic Parameters and Arguments[wardenNScaiyi](https://github.com/wardenNScaiyi)
- Summary of the Grammar[miaosiqi](https://github.com/miaosiqi)
# 1.0 译者记录
* 欢迎使用 Swift
* 关于 Swift ([numbbbbb])
* Swift 初见 ([numbbbbb])
* Swift 教程
* 基础部分 ([numbbbbb], [lyuka], [JaySurplus])
* 基本操作符 ([xielingwang])
* 字符串和字符 ([wh1100717])
* 集合类型 ([zqp])
* 控制流 ([vclwei], [coverxit], [NicePiao])
* 函数 ([honghaoz])
* 闭包 ([wh1100717])
* 枚举 ([yankuangshi])
* 类和结构体 ([JaySurplus])
* 属性 ([shinyzhu])
* 方法 ([pp-prog])
* 下标 ([siemenliu])
* 继承 ([Hawstein])
* 构造过程 ([lifedim])
* 析构过程 ([bruce0505])
* 自动引用计数 ([TimothyYe])
* 可选链 ([Jasonbroker])
* 类型检查 ([xiehurricane])
* 嵌套类型 ([Lin-H])
* 扩展 ([lyuka])
* 协议 ([geek5nan])
* 泛型 ([takalard])
* 高级操作符 ([xielingwang])
* 语言参考
* 关于语言参考 ([dabing1022])
* 词法结构 ([superkam])
* 类型 ([lyuka])
* 表达式 ([sg552] )
* 语句 ([coverxit])
* 声明 ([marsprince])
* 特性 ([Hawstein])
* 模式 ([honghaoz])
* 泛型参数 ([fd5788])
* 语法总结 ([StanZhai])
# 贡献力量
如果想做出贡献的话,你可以:
@ -127,9 +25,6 @@ Language Reference:
- 提出修改建议
- 提出术语翻译建议
# 翻译术语参照表
# 翻译建议
@ -141,6 +36,8 @@ Language Reference:
- 工作分支为gh-pages用于GitHub的pages服务
- fork过去之后新建一个分支进行翻译完成后pull request这个分支没问题的话我会合并到gh-pages分支中
- 有其他任何问题都欢迎发issue我看到了会尽快回复
- 翻译排版格式要求参考 SwiftGG 博客翻译要求[详见](https://github.com/SwiftGGTeam/translation/blob/master/SwiftGG%20排版指南.md)
- 翻译流程参考 SwiftGG 博客翻译流程[详见](https://github.com/SwiftGGTeam/translation/blob/master/翻译流程详细说明.md#翻译)
谢谢!
@ -222,7 +119,7 @@ Language Reference:
- 如果对术语参照表有疑问或者建议可以提 Issues 进行讨论
- 如果以上两条都没有找到合适的结果,请自己决定一个合适的翻译或者直接使用英文原文,后期校对的时候会进行统一
# 参考流程
# Fork 工作流参考流程
有些朋友可能不太清楚如何帮忙翻译,我这里写一个简单的流程,大家可以参考一下:
@ -241,65 +138,12 @@ Language Reference:
修改之后,首先 push 到你的库,然后登录 GitHub在你的库的首页可以看到一个 `pull request` 按钮,点击它,填写一些说明信息,然后提交即可。
# 贡献历史
## 简体中文版贡献历史
1. Welcome To Swift 翻译贡献榜[详情](https://github.com/SwiftGGTeam/the-swift-programming-language-in-chinese/tree/gh-pages/source/chapter1/05_contributors.md)
2. Language Guide 翻译贡献榜[详情](https://github.com/SwiftGGTeam/the-swift-programming-language-in-chinese/blob/gh-pages/source/chapter2/27_contributors.md)
# 开源协议
基于[WTFPL](http://en.wikipedia.org/wiki/WTFPL)协议开源。
[numbbbbb]:https://github.com/numbbbbb
[stanzhai]:https://github.com/stanzhai
[coverxit]:https://github.com/coverxit
[wh1100717]:https://github.com/wh1100717
[TimothyYe]:https://github.com/TimothyYe
[honghaoz]:https://github.com/honghaoz
[lyuka]:https://github.com/lyuka
[JaySurplus]:https://github.com/JaySurplus
[Hawstein]:https://github.com/Hawstein
[geek5nan]:https://github.com/geek5nan
[yankuangshi]:https://github.com/yankuangshi
[xielingwang]:https://github.com/xielingwang
[yulingtianxia]:https://github.com/yulingtianxia
[twlkyao]:https://github.com/twlkyao
[dabing1022]:https://github.com/dabing1022
[vclwei]:https://github.com/vclwei
[fd5788]:https://github.com/fd5788
[siemenliu]:https://github.com/siemenliu
[youkugems]:https://github.com/youkugems
[haolloyin]:https://github.com/haolloyin
[wxstars]:https://github.com/wxstars
[IceskYsl]:https://github.com/IceskYsl
[sg552]:https://github.com/sg552
[superkam]:https://github.com/superkam
[zac1st1k]:https://github.com/zac1st1k
[bzsy]:https://github.com/bzsy
[pyanfield]:https://github.com/pyanfield
[ericzyh]:https://github.com/ericzyh
[peiyucn]:https://github.com/peiyucn
[sunfiled]:https://github.com/sunfiled
[lzw120]:https://github.com/lzw120
[viztor]:https://github.com/viztor
[wongzigii]:https://github.com/wongzigii
[umcsdon]:https://github.com/umcsdon
[zq54zquan]:https://github.com/zq54zquan
[xiehurricane]:https://github.com/xiehurricane
[Jasonbroker]:https://github.com/Jasonbroker
[tualatrix]:https://github.com/tualatrix
[pp-prog]:https://github.com/pp-prog
[088haizi]:https://github.com/088haizi
[baocaixiong]:https://github.com/baocaixiong
[yeahdongcn]:https://github.com/yeahdongcn
[shinyzhu]:https://github.com/shinyzhu
[lslxdx]:https://github.com/lslxdx
[Evilcome]:https://github.com/Evilcome
[zqp]:https://github.com/zqp
[NicePiao]:https://github.com/NicePiao
[LunaticM]:https://github.com/LunaticM
[menlongsheng]:https://github.com/menlongsheng
[lifedim]:https://github.com/lifedim
[happyming]:https://github.com/happyming
[bruce0505]:https://github.com/bruce0505
[Lin-H]:https://github.com/Lin-H
[takalard]:https://github.com/takalard
[dabing1022]:https://github.com/dabing1022
[marsprince]:https://github.com/marsprince

View File

@ -1,27 +1,4 @@
# 关于 SwiftAbout Swift
-----------------
> 1.0
> 翻译:[numbbbbb](https://github.com/numbbbbb)
> 校对:[yeahdongcn](https://github.com/yeahdongcn)
> 2.0
> 翻译+校对:[xtymichael](https://github.com/xtymichael)
> 3.0
> 翻译+校对:[shanks](http://codebuild.me)2016-10-06
> 3.0.1
> review : 2016-11-09
> 3.1
> 校对: [SketchK](https://github.com/SketchK) 2017-04-08
> 4.0
> 翻译:[rain2540](https://github.com/rain2540) 2017-09-21
> 4.1
> 翻译:[mylittleswift](https://github.com/mylittleswift)
# 关于 Swift
Swift 是一种非常好的编写软件的方式,无论是手机,台式机,服务器,还是其他运行代码的设备。它是一种安全,快速和互动的编程语言,将现代编程语言的精华和苹果工程师文化的智慧,以及来自开源社区的多样化贡献结合了起来。编译器对性能进行了优化,编程语言对开发进行了优化,两者互不干扰,鱼与熊掌兼得。

View File

@ -1,11 +1,4 @@
# 版本兼容性
-----------------
> 4.0
> 翻译:[muhlenXi](https://github.com/muhlenxi) 2017-09-25
> 4.1
> 翻译:[mylittleswift](https://github.com/mylittleswift)
本书描述的是 Swift 4.1,是 Xcode 9.2 中包含的默认版本。你可以用 Xcode 9.2 来构建用 Swift 4 或 Swift 3 写的项目。

View File

@ -1,42 +1,4 @@
# Swift 初见A Swift Tour
---
> 1.0
> 翻译:[numbbbbb](https://github.com/numbbbbb)
> 校对:[shinyzhu](https://github.com/shinyzhu), [stanzhai](https://github.com/stanzhai)
> 2.0
> 翻译+校对:[xtymichael](https://github.com/xtymichael)
> 2.2
> 翻译:[175](https://github.com/Brian175)2016-04-09
> 校对:[SketchK](https://github.com/SketchK)2016-05-11
> 3.0
> 翻译+校对:[shanks](http://codebuild.me)2016-10-06
> 3.0.1
> review: 2016-11-09
> 3.1 校对: [SketchK](https://github.com/SketchK) 2017-04-08
> 4.0
> 翻译+校对:[muhlenxi](https://github.com/muhlenxi) 2017-09-26
> 4.1
> 翻译:[mylittleswift](https://github.com/mylittleswift)
本页内容包括:
- [简单值Simple Values](#simple_values)
- [控制流Control Flow](#control_flow)
- [函数和闭包Functions and Closures](#functions_and_closures)
- [对象和类Objects and Classes](#objects_and_classes)
- [枚举和结构体Enumerations and Structures](#enumerations_and_structures)
- [协议和扩展Protocols and Extensions](#protocols_and_extensions)
- [错误处理Error Handling](#error_handling)
- [泛型Generics](#generics)
# Swift 初见
通常来说,编程语言教程中的第一个程序应该在屏幕上打印 “Hello, world”。在 Swift 中,可以用一行代码实现:

View File

@ -1,46 +1,5 @@
# Swift 文档修订历史
---
> 1.0
> 翻译:[成都老码团队翻译组-Arya](http://weibo.com/littlekok/)
> 校对:[成都老码团队翻译组-Oberyn](http://weibo.com/u/5241713117)
[changkun](http://changkun.us/about/)
>
> 1.1
> 翻译:[成都老码团队翻译组-Arya](http://weibo.com/littlekok/)
> 校对:[成都老码团队翻译组-Oberyn](http://weibo.com/u/5241713117)
[changkun](http://changkun.us/about/)
>
> 1.2
> 翻译:[成都老码团队翻译组-Arya](http://weibo.com/littlekok/)
> 校对:[成都老码团队翻译组-Oberyn](http://weibo.com/u/5241713117)
[changkun](http://changkun.us/about/)
>
> 2.0
> 翻译+校对:[changkun](http://changkun.us/about/)
>
> 2.1
> 翻译+校对:[changkun](http://changkun.us/about/)
>
> 2.2
> 翻译+校对:[changkun](http://changkun.us/about/)
>
> 3.0
> 翻译+校对:[shanks](http://codebuild.me)2016-10-06
>
> 3.0.1
> 翻译+校对:[shanks](http://codebuild.me)2016-11-10
>
> 3.1
> 翻译+校对:[bq](https://github.com/bqlin)2018-02-22
>
> 4.0
> 翻译+校对:[bq](https://github.com/bqlin)2018-02-22
>
> 4.1
> 翻译+校对:[bq](https://github.com/bqlin)2018-02-22
本页面根据 [Document Revision History](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/RevisionHistory.html) 进行适配更新。
本页内容包括:

View File

@ -0,0 +1,101 @@
# 翻译历史记录
## About Swift
> 1.0
> 翻译:[numbbbbb](https://github.com/numbbbbb)
> 校对:[yeahdongcn](https://github.com/yeahdongcn)
> 2.0
> 翻译+校对:[xtymichael](https://github.com/xtymichael)
> 3.0
> 翻译+校对:[shanks](http://codebuild.me)2016-10-06
> 3.0.1
> review : 2016-11-09
> 3.1
> 校对: [SketchK](https://github.com/SketchK) 2017-04-08
> 4.0
> 翻译:[rain2540](https://github.com/rain2540) 2017-09-21
> 4.1
> 翻译:[mylittleswift](https://github.com/mylittleswift)
## Version Compatibility
> 4.0
> 翻译:[muhlenXi](https://github.com/muhlenxi) 2017-09-25
> 4.1
> 翻译:[mylittleswift](https://github.com/mylittleswift)
## A Swift Tour
> 1.0
> 翻译:[numbbbbb](https://github.com/numbbbbb)
> 校对:[shinyzhu](https://github.com/shinyzhu), [stanzhai](https://github.com/stanzhai)
> 2.0
> 翻译+校对:[xtymichael](https://github.com/xtymichael)
> 2.2
> 翻译:[175](https://github.com/Brian175)2016-04-09
> 校对:[SketchK](https://github.com/SketchK)2016-05-11
> 3.0
> 翻译+校对:[shanks](http://codebuild.me)2016-10-06
> 3.0.1
> review: 2016-11-09
> 3.1 校对: [SketchK](https://github.com/SketchK) 2017-04-08
> 4.0
> 翻译+校对:[muhlenxi](https://github.com/muhlenxi) 2017-09-26
> 4.1
> 翻译:[mylittleswift](https://github.com/mylittleswift)
## Revision History
> 1.0
> 翻译:[成都老码团队翻译组-Arya](http://weibo.com/littlekok/)
> 校对:[成都老码团队翻译组-Oberyn](http://weibo.com/u/5241713117)
[changkun](http://changkun.us/about/)
>
> 1.1
> 翻译:[成都老码团队翻译组-Arya](http://weibo.com/littlekok/)
> 校对:[成都老码团队翻译组-Oberyn](http://weibo.com/u/5241713117)
[changkun](http://changkun.us/about/)
>
> 1.2
> 翻译:[成都老码团队翻译组-Arya](http://weibo.com/littlekok/)
> 校对:[成都老码团队翻译组-Oberyn](http://weibo.com/u/5241713117)
[changkun](http://changkun.us/about/)
>
> 2.0
> 翻译+校对:[changkun](http://changkun.us/about/)
>
> 2.1
> 翻译+校对:[changkun](http://changkun.us/about/)
>
> 2.2
> 翻译+校对:[changkun](http://changkun.us/about/)
>
> 3.0
> 翻译+校对:[shanks](http://codebuild.me)2016-10-06
>
> 3.0.1
> 翻译+校对:[shanks](http://codebuild.me)2016-11-10
>
> 3.1
> 翻译+校对:[bq](https://github.com/bqlin)2018-02-22
>
> 4.0
> 翻译+校对:[bq](https://github.com/bqlin)2018-02-22
>
> 4.1
> 翻译+校对:[bq](https://github.com/bqlin)2018-02-22

View File

@ -1,62 +1,5 @@
# 基础部分The Basics
-----------------
# 基础部分
> 1.0
> 翻译:[numbbbbb](https://github.com/numbbbbb), [lyuka](https://github.com/lyuka), [JaySurplus](https://github.com/JaySurplus)
> 校对:[lslxdx](https://github.com/lslxdx)
> 2.0
> 翻译+校对:[xtymichael](https://github.com/xtymichael)
> 2.1
> 翻译:[Prayer](https://github.com/futantan)
> 校对:[shanks](http://codebuild.me)[overtrue](https://github.com/overtrue)
> 2.2
> 校对:[SketchK](https://github.com/SketchK)
> 3.0
> 校对:[CMB](https://github.com/chenmingbiao)版本时间2016-09-13
> 3.0.1, 2016-11-11shanks
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io)
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [常量和变量](#constants_and_variables)
- [声明常量和变量](#declaring)
- [类型标注](#type_annotations)
- [常量和变量的命名](#naming)
- [输出常量和变量](#printing)
- [注释](#comments)
- [分号](#semicolons)
- [整数](#integers)
- [整数范围](#integer_bounds)
- [Int](#Int)
- [UInt](#UInt)
- [浮点数](#floating-point_numbers)
- [类型安全和类型推断](#type_safety_and_type_inference)
- [数值型字面量](#numeric_literals)
- [数值型类型转换](#numeric_type_conversion)
- [整数转换](#integer_conversion)
- [数整数和浮点数转换](#integer_and_floating_point_conversion)
- [类型别名](#type_aliases)
- [布尔值](#booleans)
- [元组](#tuples)
- [可选类型](#optionals)
- [nil](#nil)
- [if 语句以及强制解析](#if)
- [可选绑定](#optional_binding)
- [隐式解析可选类型](#implicityly_unwrapped_optionals)
- [错误处理](#error_handling)
- [断言和先决条件](#assertions_and_preconditions)
- [使用断言进行调试](#debugging_with_assertions)
- [强制执行先决条件](#enforcing_preconditions)
Swift 是一门开发 iOS, macOS, watchOS 和 tvOS 应用的新语言。然而,如果你有 C 或者 Objective-C 开发经验的话,你会发现 Swift 的很多内容都是你熟悉的。

View File

@ -1,43 +1,4 @@
# 基本运算符Basic Operators
-----------------
> 1.0
> 翻译:[XieLingWang](https://github.com/xielingwang)
> 校对:[EvilCome](https://github.com/Evilcome)
> 2.0
> 翻译+校对:[JackAlan](https://github.com/AlanMelody)
> 2.1
> 校对:[shanks](http://codebuild.me)
> 2.2
> 翻译+校对:[Cee](https://github.com/Cee) 校对:[SketchK](https://github.com/SketchK)2016-05-11
> 3.0.1shanks2016-11-11
> 4.0
> 翻译+校对:[kemchenj](https://kemchenj.github.io)
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [术语](#terminology)
- [赋值运算符](#assignment_operator)
- [算术运算符](#arithmetic_operators)
- [求余运算符](#remainder_operator)
- [一元负号运算符](#unary_minus_operator)
- [一元正号运算符](#unary_plus_operator)
- [组合赋值运算符](#compound_assignment_operators)
- [比较运算符](#comparison_operators)
- [三目运算符](#ternary_conditional_operator)
- [空合运算符](#nil_coalescing_operator)
- [区间运算符](#range_operators)
- [闭区间运算符](#closed_range_operator)
- [半开区间运算符](#half-open_range_operator)
- [单侧区间](#one-sided_ranges)
- [逻辑运算符](#logical_operators)
# 基本运算符
*运算符*是检查、改变、合并值的特殊符号或短语。例如,加号(`+`)将两个数相加(如 `let i = 1 + 2`)。更复杂的运算例子包括逻辑与运算符 `&&`(如 `if enteredDoorCode && passedRetinaScan`)。

View File

@ -1,46 +1,4 @@
# 字符串和字符Strings and Characters
---
> 1.0
> 翻译:[wh1100717](https://github.com/wh1100717)
> 校对:[Hawstein](https://github.com/Hawstein)
> 2.0
> 翻译+校对:[DianQK](https://github.com/DianQK)
> 2.1
> 翻译:[DianQK](https://github.com/DianQK)
> 校对:[shanks](http://codebuild.me), [Realank](https://github.com/Realank),
> 2.2
> 校对:[SketchK](https://github.com/SketchK)
> 3.0
> 校对:[CMB](https://github.com/chenmingbiao)版本日期2016-09-13
> 3.0.1, shanks, 2016-11-11
> 4.0
> 翻译:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [字符串字面量](#string_literals)
- [字面量中的特殊字符](#special_characters_in_string_literals)
- [初始化空字符串](#initializing_an_empty_string)
- [字符串可变性](#string_mutability)
- [字符串是值类型](#strings_are_value_types)
- [使用字符](#working_with_characters)
- [连接字符串和字符](#concatenating_strings_and_characters)
- [字符串插值](#string_interpolation)
- [Unicode](#unicode)
- [计算字符数量](#counting_characters)
- [访问和修改字符串](#accessing_and_modifying_a_string)
- [子字符串](#substrings)
- [比较字符串](#comparing_strings)
- [字符串的 Unicode 表示形式](#unicode_representations_of_strings)
# 字符串和字符
*字符串*是是一系列字符的集合,例如 `"hello, world"``"albatross"`。Swift 的字符串通过 `String` 类型来表示。
一个 `String` 的内容可以用许多方式读取,包括作为一个 `Character` 值的集合。

View File

@ -1,52 +1,4 @@
# 集合类型Collection Types
-----------------
> 1.0
> 翻译:[zqp](https://github.com/zqp)
> 校对:[shinyzhu](https://github.com/shinyzhu), [stanzhai](https://github.com/stanzhai), [feiin](https://github.com/feiin)
> 2.0
> 翻译+校对:[JackAlan](https://github.com/AlanMelody)
> 2.1
> 校对:[shanks](http://codebuild.me)
> 2.2
> 校对:[SketchK](https://github.com/SketchK) 2016-05-11
> 3.0
> 校对:[shanks](http://codebuild.me) 2016-10-09
> 3.0.1shanks2016-11-12
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [集合的可变性](#mutability_of_collections)
- [数组](#arrays)
- [创建一个空数组](#creating_an_empty_array)
- [创建一个带有默认值的数组](#creating_an_array_with_a_default_value)
- [通过两个数组相加创建一个数组](#creating_an_array_by_adding_two_arrays_together)
- [用数组字面量构造数组](#creating_an_array_with_an_array_literals)
- [访问和修改数组](#accessing_and_modifying_an_array)
- [数组的遍历](#iterating_over_an_array)
- [集合](#sets)
- [集合类型的哈希值](#hash_values_for_set_types)
- [集合类型语法](#set_type_syntax)
- [创建和构造一个空的集合](#creating_and_initalizing_an_empty_set)
- [用数组字面量创建集合](#creating_a_set_with_an_array_literal)
- [访问和修改一个集合](#accesing_and_modifying_a_set)
- [遍历一个集合](#iterating_over_a_set)
- [集合操作](#performing_set_operations)
- [基本集合操作](#fundamental_set_operations)
- [集合成员关系和相等](#set_membership_and_equality)
- [字典](#dictionaries)
- [字典类型简化语法](#dictionary_type_shorthand_syntax)
- [创建一个空字典](#creating_an_empty_dictionary)
- [用字典字面量创建字典](#creating_a_dictionary_with_a_dictionary_literal)
- [访问和修改字典](#accessing_and_modifying_a_dictionary)
- [字典遍历](#iterating_over_a_dictionary)
# 集合类型
Swift 语言提供 `Arrays``Sets``Dictionaries` 三种基本的*集合类型*用来存储集合数据。数组Arrays是有序数据的集。集合Sets是无序无重复数据的集。字典Dictionaries是无序的键值对的集。

View File

@ -1,42 +1,4 @@
# 控制流Control Flow
-----------------
> 1.0
> 翻译:[vclwei](https://github.com/vclwei), [coverxit](https://github.com/coverxit), [NicePiao](https://github.com/NicePiao)
> 校对:[coverxit](https://github.com/coverxit), [stanzhai](https://github.com/stanzhai)
> 2.0
> 翻译+校对:[JackAlan](https://github.com/AlanMelody)
> 2.1
> 翻译:[Prayer](https://github.com/futantan)
> 校对:[shanks](http://codebuild.me)
> 2.2
> 翻译:[LinusLing](https://github.com/linusling)
> 校对:[SketchK](https://github.com/SketchK)
> 3.0
> 翻译:[Realank](https://github.com/realank) 2016-09-13
> 3.0.1shanks2016-11-12
> 3.1
> 翻译:[qhd](https://github.com/qhd) 2017-04-17
> 4.0
> 翻译:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [For-In 循环](#for_in_loops)
- [While 循环](#while_loops)
- [条件语句](#conditional_statement)
- [控制转移语句Control Transfer Statements](#control_transfer_statements)
- [提前退出](#early_exit)
- [检测 API 可用性](#checking_api_availability)
# 控制流
Swift 提供了多种流程控制结构,包括可以多次执行任务的 `while` 循环,基于特定条件选择执行不同代码分支的 `if``guard``switch` 语句,还有控制流程跳转到其他代码位置的 `break``continue` 语句。

View File

@ -1,38 +1,4 @@
# 函数Functions
-----------------
> 1.0
> 翻译:[honghaoz](https://github.com/honghaoz)
> 校对:[LunaticM](https://github.com/LunaticM)
> 2.0
> 翻译+校对:[dreamkidd](https://github.com/dreamkidd)
> 2.1
> 翻译:[DianQK](https://github.com/DianQK)
> 定稿:[shanks](http://codebuild.me)
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-12
> 3.0
> 翻译: [crayygy](https://github.com/crayygy) 2016-09-12
> 校对: [shanks](http://codebuild.me) 2016-09-27
> 3.0.1shanks2016-11-12
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [函数定义与调用](#Defining_and_Calling_Functions)
- [函数参数与返回值](#Function_Parameters_and_Return_Values)
- [函数参数标签和参数名称](#Function_Argument_Labels_and_Parameter_Names)
- [函数类型](#Function_Types)
- [嵌套函数](#Nested_Functions)
# 函数
*函数*是一段完成特定任务的独立代码片段。你可以通过给函数命名来标识某个函数的功能,这个名字可以被用来在需要的时候“调用”这个函数来完成它的任务。

View File

@ -1,39 +1,4 @@
# 闭包Closures
-----------------
> 1.0
> 翻译:[wh1100717](https://github.com/wh1100717)
> 校对:[lyuka](https://github.com/lyuka)
> 2.0
> 翻译+校对:[100mango](https://github.com/100mango)
> 2.1
> 翻译:[100mango](https://github.com/100mango), [magicdict](https://github.com/magicdict)
> 校对:[shanks](http://codebuild.me)
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-12
> 3.0
> 翻译:[Lanford](https://github.com/LanfordCai) 2016-09-19
> 3.0.1shanks2016-11-12
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [闭包表达式](#closure_expressions)
- [尾随闭包](#trailing_closures)
- [值捕获](#capturing_values)
- [闭包是引用类型](#closures_are_reference_types)
- [逃逸闭包](#escaping_closures)
- [自动闭包](#autoclosures)
# 闭包
*闭包*是自包含的函数代码块可以在代码中被传递和使用。Swift 中的闭包与 C 和 Objective-C 中的代码块blocks以及其他一些编程语言中的匿名函数比较相似。

View File

@ -1,37 +1,4 @@
# 枚举Enumerations
---
> 1.0
> 翻译:[yankuangshi](https://github.com/yankuangshi)
> 校对:[shinyzhu](https://github.com/shinyzhu)
> 2.0
> 翻译+校对:[futantan](https://github.com/futantan)
> 2.1
> 翻译:[Channe](https://github.com/Channe)
> 校对:[shanks](http://codebuild.me)
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-13
> 3.0
> 翻译+校对:[shanks](https://codebuild.me) 2016-09-24
> 3.0.1shanks2016-11-12
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页内容包含:
- [枚举语法](#enumeration_syntax)
- [使用 Switch 语句匹配枚举值](#matching_enumeration_values_with_a_switch_statement)
- [关联值](#associated_values)
- [原始值](#raw_values)
- [递归枚举](#recursive_enumerations)
# 枚举
*枚举*为一组相关的值定义了一个共同的类型,使你可以在你的代码中以类型安全的方式来使用这些值。

View File

@ -1,34 +1,5 @@
# 类和结构体
> 1.0
> 翻译:[JaySurplus](https://github.com/JaySurplus)
> 校对:[sg552](https://github.com/sg552)
> 2.0
> 翻译+校对:[SkyJean](https://github.com/SkyJean)
> 2.1
> 校对:[shanks](http://codebuild.me)2015-10-29
> 2.2
> 校对:[SketchK](https://github.com/SketchK) 2016-05-13
>
> 3.0.1 shanks 2016-11-12
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [类和结构体对比](#comparing_classes_and_structures)
- [结构体和枚举是值类型](#structures_and_enumerations_are_value_types)
- [类是引用类型](#classes_are_reference_types)
- [类和结构体的选择](#choosing_between_classes_and_structures)
- [字符串、数组、和字典类型的赋值与复制行为](#assignment_and_copy_behavior_for_strings_arrays_and_dictionaries)
*类*和*结构体*是人们构建代码所用的一种通用且灵活的构造体。我们可以使用完全相同的语法规则来为类和结构体定义属性(常量、变量)和添加方法,从而扩展类和结构体的功能。
与其他编程语言所不同的是Swift 并不要求你为自定义类和结构去创建独立的接口和实现文件。你所要做的是在一个单一文件中定义一个类或者结构体,系统将会自动生成面向其它代码的外部接口。

View File

@ -1,35 +1,4 @@
# 属性Properties
---
> 1.0
> 翻译:[shinyzhu](https://github.com/shinyzhu)
> 校对:[pp-prog](https://github.com/pp-prog) [yangsiy](https://github.com/yangsiy)
> 2.0
> 翻译+校对:[yangsiy](https://github.com/yangsiy)
> 2.1
> 翻译:[buginux](https://github.com/buginux)
> 校对:[shanks](http://codebuild.me)2015-10-29
> 2.2
> 翻译:[saitjr](https://github.com/saitjr)2016-04-11[SketchK](https://github.com/SketchK) 2016-05-13
>
> 3.0.1shanks2016-11-12
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [存储属性](#stored_properties)
- [计算属性](#computed_properties)
- [属性观察器](#property_observers)
- [全局变量和局部变量](#global_and_local_variables)
- [类型属性](#type_properties)
# 属性
*属性*将值跟特定的类、结构或枚举关联。存储属性存储常量或变量作为实例的一部分,而计算属性计算(不是存储)一个值。计算属性可以用于类、结构体和枚举,存储属性只能用于类和结构体。

View File

@ -1,31 +1,4 @@
# 方法Methods
-----------------
> 1.0
> 翻译:[pp-prog](https://github.com/pp-prog)
> 校对:[zqp](https://github.com/zqp)
> 2.0
> 翻译+校对:[DianQK](https://github.com/DianQK)
> 2.1
> 翻译:[DianQK](https://github.com/DianQK)[Realank](https://github.com/Realank) 校对:[shanks](http://codebuild.me)2016-01-18
> 2.2
> 校对:[SketchK](https://github.com/SketchK) 2016-05-13
> 3.0.1shanks2016-11-13
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [实例方法](#instance_methods)
- [类型方法](#type_methods)
# 方法
*方法*是与某些特定类型相关联的函数。类、结构体、枚举都可以定义实例方法;实例方法为给定类型的实例封装了具体的任务与功能。类、结构体、枚举也可以定义类型方法;类型方法与类型本身相关联。类型方法与 Objective-C 中的类方法class methods相似。

View File

@ -1,31 +1,4 @@
# 下标
-----------------
> 1.0
> 翻译:[siemenliu](https://github.com/siemenliu)
> 校对:[zq54zquan](https://github.com/zq54zquan)
> 2.0
> 翻译+校对:[shanks](http://codebuild.me)
> 2.1
> 翻译+校对:[shanks](http://codebuild.me)[Realank](https://github.com/Realank)
> 2.2
> 校对:[SketchK](https://github.com/SketchK) 2016-05-13
> 3.0.1shanks2016-11-13
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [下标语法](#subscript_syntax)
- [下标用法](#subscript_usage)
- [下标选项](#subscript_options)
*下标*可以定义在类、结构体和枚举中,是访问集合、列表或序列中元素的快捷方式。可以使用下标的索引,设置和获取值,而不需要再调用对应的存取方法。举例来说,用下标访问一个 `Array` 实例中的元素可以写作 `someArray[index]`,访问 `Dictionary` 实例中的元素可以写作 `someDictionary[key]`

View File

@ -1,30 +1,4 @@
# 继承
-------------------
> 1.0
> 翻译:[Hawstein](https://github.com/Hawstein)
> 校对:[menlongsheng](https://github.com/menlongsheng)
> 2.02.1
> 翻译+校对:[shanks](http://codebuild.me)
> 2.2
> 校对:[SketchK](https://github.com/SketchK) 2016-05-13
> 3.0.1shanks2016-11-13
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [定义一个基类](#defining_a_base_class)
- [子类生成](#subclassing)
- [重写](#overriding)
- [防止重写](#preventing_overrides)
一个类可以*继承*另一个类的方法,属性和其它特性。当一个类继承其它类时,继承类叫*子类*,被继承类叫*超类(或父类)*。在 Swift 中,继承是区分「类」与其它类型的一个基本特征。

View File

@ -1,41 +1,4 @@
# 构造过程
-----------------
> 1.0
> 翻译:[lifedim](https://github.com/lifedim)
> 校对:[lifedim](https://github.com/lifedim)
> 2.0
> 翻译+校对:[chenmingbiao](https://github.com/chenmingbiao)
> 2.1
> 翻译:[Channe](https://github.com/Channe)[Realank](https://github.com/Realank)
> 校对:[shanks](http://codebuild.me)2016-1-23
> 2.2
> 翻译:[pmst](https://github.com/colourful987)
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-14
> 3.0.1shanks2016-11-13
> 3.1
> 翻译:[qhd](https://github.com/qhd) 2017-04-18
> 4.0
> 翻译:[muhlenXi](https://github.com/muhlenxi) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [存储属性的初始赋值](#setting_initial_values_for_stored_properties)
- [自定义构造过程](#customizing_initialization)
- [默认构造器](#default_initializers)
- [值类型的构造器代理](#initializer_delegation_for_value_types)
- [类的继承和构造过程](#class_inheritance_and_initialization)
- [可失败构造器](#failable_initializers)
- [必要构造器](#required_initializers)
- [通过闭包或函数设置属性的默认值](#setting_a_default_property_value_with_a_closure_or_function)
*构造过程*是使用类、结构体或枚举类型的实例之前的准备过程。在新实例可用前必须执行这个过程,具体操作包括设置实例中每个存储型属性的初始值和执行其他必须的设置或初始化工作。

View File

@ -1,31 +1,4 @@
# 析构过程
---------------------------
> 1.0
> 翻译:[bruce0505](https://github.com/bruce0505)
> 校对:[fd5788](https://github.com/fd5788)
> 2.0
> 翻译+校对:[chenmingbiao](https://github.com/chenmingbiao)
> 2.1
> 校对:[shanks](http://codebuild.me)2015-10-31
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-14
> 3.0.1shanks2016-11-13
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [析构过程原理](#how_deinitialization_works)
- [析构器实践](#deinitializers_in_action)
*析构器*只适用于类类型,当一个类的实例被释放之前,析构器会被立即调用。析构器用关键字 `deinit` 来标示,类似于构造器要用 `init` 来标示。

View File

@ -1,38 +1,5 @@
# 可选链式调用
-----------------
> 1.0
> 翻译:[Jasonbroker](https://github.com/Jasonbroker)
> 校对:[numbbbbb](https://github.com/numbbbbb), [stanzhai](https://github.com/stanzhai)
> 2.0
> 翻译+校对:[lyojo](https://github.com/lyojo)
> 2.1
> 校对:[shanks](http://codebuild.me)2015-10-31
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-15
> 3.0.1shanks2016-11-13
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [使用可选链式调用代替强制展开](#optional_chaining_as_an_alternative_to_forced_unwrapping)
- [为可选链式调用定义模型类](#defining_model_classes_for_optional_chaining)
- [通过可选链式调用访问属性](#accessing_properties_through_optional_chaining)
- [通过可选链式调用调用方法](#calling_methods_through_optional_chaining)
- [通过可选链式调用访问下标](#accessing_subscripts_through_optional_chaining)
- [连接多层可选链式调用](#linking_multiple_levels_of_chaining)
- [在方法的可选返回值上进行可选链式调用](#chaining_on_methods_with_optional_return_values)
*可选链式调用*是一种可以在当前值可能为 `nil` 的可选值上请求和调用属性、方法及下标的方法。如果可选值有值,那么调用就会成功;如果可选值是 `nil`,那么调用将返回 `nil`。多个调用可以连接在一起形成一个调用链,如果其中任何一个节点为 `nil`,整个调用链都会失败,即返回 `nil`
> 注意

View File

@ -1,29 +1,4 @@
# 错误处理
-----------------
> 2.1
> 翻译+校对:[lyojo](https://github.com/lyojo) [ray16897188](https://github.com/ray16897188) 2015-10-23
> 校对:[shanks](http://codebuild.me) 2015-10-24
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-15
> 3.0
> 翻译+校对:[shanks](http://codebuild.me) 2016-09-24
> 3.0.1shanks2016-11-13
> 4.0
> 翻译+校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [表示并抛出错误](#representing_and_throwing_errors)
- [处理错误](#handling_errors)
- [指定清理操作](#specifying_cleanup_actions)
*错误处理Error handling*是响应错误以及从错误中恢复的过程。Swift 提供了在运行时对可恢复错误的抛出、捕获、传递和操作的一等公民支持。

View File

@ -1,32 +1,4 @@
# 类型转换
-----------------
> 1.0
> 翻译:[xiehurricane](https://github.com/xiehurricane)
> 校对:[happyming](https://github.com/happyming)
> 2.0
> 翻译+校对:[yangsiy](https://github.com/yangsiy)
> 2.1
> 校对:[shanks](http://codebuild.me)2015-11-01
>
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-16
> 3.0.1shanks2016-11-13
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [定义一个类层次作为例子](#defining_a_class_hierarchy_for_type_casting)
- [检查类型](#checking_type)
- [向下转型](#downcasting)
- [`Any` 和 `AnyObject` 的类型转换](#type_casting_for_any_and_anyobject)
*类型转换*可以判断实例的类型,也可以将实例看做是其父类或者子类的实例。

View File

@ -1,30 +1,4 @@
# 嵌套类型
-----------------
> 1.0
> 翻译:[Lin-H](https://github.com/Lin-H)
> 校对:[shinyzhu](https://github.com/shinyzhu)
> 2.0
> 翻译+校对:[SergioChan](https://github.com/SergioChan)
> 2.1
> 校对:[shanks](http://codebuild.me)2015-11-01
>
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-16
> 3.0.1shanks2016-11-13
> 4.0
> 翻译+校对:[EyreFree](https://www.eyrefree.org/) 2017-10-19
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [嵌套类型实践](#nested_types_in_action)
- [引用嵌套类型](#referring_to_nested_types)
枚举常被用于为特定类或结构体实现某些功能。类似地枚举可以方便的定义工具类或结构体从而为某个复杂的类型所使用。为了实现这种功能Swift 允许你定义*嵌套类型*,可以在支持的类型中定义嵌套的枚举、类和结构体。

View File

@ -1,34 +1,4 @@
# 扩展
---------------
> 1.0
> 翻译:[lyuka](https://github.com/lyuka)
> 校对:[Hawstein](https://github.com/Hawstein)
> 2.0
> 翻译+校对:[shanks](http://codebuild.me)
> 2.1
> 校对:[shanks](http://codebuild.me)
>
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-16
> 3.0.1shanks2016-11-13
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [扩展语法](#extension_syntax)
- [计算型属性](#computed_properties)
- [构造器](#initializers)
- [方法](#methods)
- [下标](#subscripts)
- [嵌套类型](#nested_types)
*扩展* 就是为一个已有的类、结构体、枚举类型或者协议类型添加新功能。这包括在没有权限获取原始源代码的情况下扩展类型的能力(即 *逆向建模* )。扩展和 Objective-C 中的分类类似。(与 Objective-C 不同的是Swift 的扩展没有名字。)

View File

@ -1,47 +1,4 @@
# 协议
-----------------
> 1.0
> 翻译:[geek5nan](https://github.com/geek5nan)
> 校对:[dabing1022](https://github.com/dabing1022)
> 2.0
> 翻译+校对:[futantan](https://github.com/futantan)
> 2.1
> 翻译:[小铁匠 Linus](https://github.com/kevin833752)
> 校对:[shanks](http://codebuild.me)
>
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK)
>
> 3.0
> 校对:[CMB](https://github.com/chenmingbiao)版本日期2016-09-13
> 3.0.1
> shanks2016-11-13
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [协议语法](#protocol_syntax)
- [属性要求](#property_requirements)
- [方法要求Method Requirements](#method_requirements)
- [Mutating 方法要求](#mutating_method_requirements)
- [构造器要求](#initializer_requirements)
- [协议作为类型](#protocols_as_types)
- [委托(代理)模式](#delegation)
- [通过扩展添加协议一致性](#adding_protocol_conformance_with_an_extension)
- [通过扩展遵循协议](#declaring_protocol_adoption_with_an_extension)
- [协议类型的集合](#collections_of_protocol_types)
- [协议的继承](#protocol_inheritance)
- [类类型专属协议](#class_only_protocol)
- [协议合成](#protocol_composition)
- [检查协议一致性](#checking_for_protocol_conformance)
- [可选的协议要求](#optional_protocol_requirements)
- [协议扩展](#protocol_extensions)
*协议* 定义了一个蓝图,规定了用来实现某一特定任务或者功能的方法、属性,以及其他需要的东西。类、结构体或枚举都可以遵循协议,并为协议定义的这些要求提供具体实现。某个类型能够满足某个协议的要求,就可以说该类型*遵循*这个协议。

View File

@ -1,43 +1,4 @@
# 泛型
-------------------
> 1.0
> 翻译:[takalard](https://github.com/takalard)
> 校对:[lifedim](https://github.com/lifedim)
> 2.0
> 翻译+校对: [SergioChan](https://github.com/SergioChan)
> 2.1
> 校对:[shanks](http://codebuild.me)2015-11-01
> 2.2:翻译+校对:[Lanford](https://github.com/LanfordCai)2016-04-08 [SketchK](https://github.com/SketchK) 2016-05-16
> 3.0:翻译+校对:[chenmingjia](https://github.com/chenmingjia)2016-09-12
> 3.0.1shanks2016-11-13
> 3.1:翻译:[qhd](https://github.com/qhd)2017-04-10
> 4.0
> 翻译+校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [泛型所解决的问题](#the_problem_that_generics_solve)
- [泛型函数](#generic_functions)
- [类型参数](#type_parameters)
- [命名类型参数](#naming_type_parameters)
- [泛型类型](#generic_types)
- [扩展一个泛型类型](#extending_a_generic_type)
- [类型约束](#type_constraints)
- [关联类型](#associated_types)
- [泛型 Where 语句](#where_clauses)
- [具有泛型 where 子句的扩展](#extensions_with_a_generic_where_clause)
- [具有泛型 Where 子句的关联类型](#associated_types_with_a_generic_where_clause)
- [泛型下标](#generic_subscripts)
*泛型代码*让你能够根据自定义的需求,编写出适用于任意类型、灵活可重用的函数及类型。它能让你避免代码的重复,用一种清晰和抽象的方式来表达代码的意图。

View File

@ -1,34 +1,4 @@
# 自动引用计数
-----------------
> 1.0
> 翻译:[TimothyYe](https://github.com/TimothyYe)
> 校对:[Hawstein](https://github.com/Hawstein)
> 2.0
> 翻译+校对:[Channe](https://github.com/Channe)
> 2.1
> 翻译:[Channe](https://github.com/Channe)
> 校对:[shanks](http://codebuild.me)[Realank](https://github.com/Realank) 2016-01-23
>
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-14
> 3.0.1
> shanks2016-11-13
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [自动引用计数的工作机制](#how_arc_works)
- [自动引用计数实践](#arc_in_action)
- [类实例之间的循环强引用](#strong_reference_cycles_between_class_instances)
- [解决实例之间的循环强引用](#resolving_strong_reference_cycles_between_class_instances)
- [闭包引起的循环强引用](#strong_reference_cycles_for_closures)
- [解决闭包引起的循环强引用](#resolving_strong_reference_cycles_for_closures)
Swift 使用*自动引用计数ARC*机制来跟踪和管理你的应用程序的内存。通常情况下Swift 内存管理机制会一直起作用你无须自己来考虑内存的管理。ARC 会在类的实例不再被使用时,自动释放其占用的内存。

View File

@ -1,20 +1,4 @@
# 内存安全
--------------------
> 4.0
> 翻译:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页包含内容:
- [理解内存访问冲突](#understanding_conflicting_access_to_memory)
- [In-Out 参数的访问冲突](#conflicting_access_to_in-out_parameters)
- [函数里 self 的访问冲突](#conflicting_access_to_self_in_methods)
- [属性的访问冲突](#conflicting_access_to_properties)
- [更新历史](#revision_history)
默认情况下Swift 会阻止你代码里不安全的行为。例如Swift 会保证变量在使用之前就完成初始化,在内存被回收之后就无法被访问,并且数组的索引会做越界检查。

View File

@ -1,42 +1,4 @@
# 访问控制
------------------
> 1.0
> 翻译:[JaceFu](http://www.devtalking.com/)
> 校对:[ChildhoodAndy](http://childhood.logdown.com)
> 2.0
> 翻译+校对:[mmoaay](https://github.com/mmoaay)
> 2.1
> 翻译:[Prayer](https://github.com/futantan)
> 校对:[shanks](http://codebuild.me)2015-11-01
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-17
> 3.0.1
> 翻译+校对: shanks2016-11-13
> 4.0
> 翻译kemchenj2017-09-23
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页内容包括:
- [模块和源文件](#modules_and_source_files)
- [访问级别](#access_levels)
- [访问控制语法](#access_control_syntax)
- [自定义类型](#custom_types)
- [子类](#subclassing)
- [常量、变量、属性、下标](#constants_variables_properties_subscripts)
- [构造器](#initializers)
- [协议](#protocols)
- [Extension](#extensions)
- [泛型](#generics)
- [类型别名](#type_aliases)
*访问控制*可以限定其它源文件或模块中的代码对你的代码的访问级别。这个特性可以让我们隐藏代码的一些实现细节,并且可以为其他人可以访问和使用的代码提供接口。

View File

@ -1,35 +1,4 @@
# 高级运算符
-----------------
> 1.0
> 翻译:[xielingwang](https://github.com/xielingwang)
> 校对:[numbbbbb](https://github.com/numbbbbb)
> 2.0
> 翻译+校对:[buginux](https://github.com/buginux)
> 2.1
> 校对:[shanks](http://codebuild.me)2015-11-01
>
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-17
>
> 3.0
> 翻译+校对:[mmoaay](https://github.com/mmoaay) 2016-09-20
> 3.0.1
> shanks2016-11-13
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
本页内容包括:
- [位运算符](#bitwise_operators)
- [溢出运算符](#overflow_operators)
- [优先级和结合性](#precedence_and_associativity)
- [运算符函数](#operator_methods)
- [自定义运算符](#custom_operators)
除了在之前介绍过的[基本运算符](./02_Basic_Operators.html)Swift 中还有许多可以对数值进行复杂运算的高级运算符。这些高级运算符包含了在 C 和 Objective-C 中已经被大家所熟知的位运算符和移位运算符。

View File

@ -0,0 +1,613 @@
# 翻译历史记录
## The Basic 章节
> 1.0
> 翻译:[numbbbbb](https://github.com/numbbbbb), [lyuka](https://github.com/lyuka), [JaySurplus](https://github.com/JaySurplus)
> 校对:[lslxdx](https://github.com/lslxdx)
> 2.0
> 翻译+校对:[xtymichael](https://github.com/xtymichael)
> 2.1
> 翻译:[Prayer](https://github.com/futantan)
> 校对:[shanks](http://codebuild.me)[overtrue](https://github.com/overtrue)
> 2.2
> 校对:[SketchK](https://github.com/SketchK)
> 3.0
> 校对:[CMB](https://github.com/chenmingbiao)版本时间2016-09-13
> 3.0.1, 2016-11-11shanks
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io)
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Basic_Operators 章节
> 1.0
> 翻译:[XieLingWang](https://github.com/xielingwang)
> 校对:[EvilCome](https://github.com/Evilcome)
> 2.0
> 翻译+校对:[JackAlan](https://github.com/AlanMelody)
> 2.1
> 校对:[shanks](http://codebuild.me)
> 2.2
> 翻译+校对:[Cee](https://github.com/Cee) 校对:[SketchK](https://github.com/SketchK)2016-05-11
> 3.0.1shanks2016-11-11
> 4.0
> 翻译+校对:[kemchenj](https://kemchenj.github.io)
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Strings_and_Characters 章节
> 1.0
> 翻译:[wh1100717](https://github.com/wh1100717)
> 校对:[Hawstein](https://github.com/Hawstein)
> 2.0
> 翻译+校对:[DianQK](https://github.com/DianQK)
> 2.1
> 翻译:[DianQK](https://github.com/DianQK)
> 校对:[shanks](http://codebuild.me), [Realank](https://github.com/Realank),
> 2.2
> 校对:[SketchK](https://github.com/SketchK)
> 3.0
> 校对:[CMB](https://github.com/chenmingbiao)版本日期2016-09-13
> 3.0.1, shanks, 2016-11-11
> 4.0
> 翻译:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Collection_Types
> 1.0
> 翻译:[zqp](https://github.com/zqp)
> 校对:[shinyzhu](https://github.com/shinyzhu), [stanzhai](https://github.com/stanzhai), [feiin](https://github.com/feiin)
> 2.0
> 翻译+校对:[JackAlan](https://github.com/AlanMelody)
> 2.1
> 校对:[shanks](http://codebuild.me)
> 2.2
> 校对:[SketchK](https://github.com/SketchK) 2016-05-11
> 3.0
> 校对:[shanks](http://codebuild.me) 2016-10-09
> 3.0.1shanks2016-11-12
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Control Flow
> 1.0
> 翻译:[vclwei](https://github.com/vclwei), [coverxit](https://github.com/coverxit), [NicePiao](https://github.com/NicePiao)
> 校对:[coverxit](https://github.com/coverxit), [stanzhai](https://github.com/stanzhai)
> 2.0
> 翻译+校对:[JackAlan](https://github.com/AlanMelody)
> 2.1
> 翻译:[Prayer](https://github.com/futantan)
> 校对:[shanks](http://codebuild.me)
> 2.2
> 翻译:[LinusLing](https://github.com/linusling)
> 校对:[SketchK](https://github.com/SketchK)
> 3.0
> 翻译:[Realank](https://github.com/realank) 2016-09-13
> 3.0.1shanks2016-11-12
> 3.1
> 翻译:[qhd](https://github.com/qhd) 2017-04-17
> 4.0
> 翻译:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Functions
> 1.0
> 翻译:[honghaoz](https://github.com/honghaoz)
> 校对:[LunaticM](https://github.com/LunaticM)
> 2.0
> 翻译+校对:[dreamkidd](https://github.com/dreamkidd)
> 2.1
> 翻译:[DianQK](https://github.com/DianQK)
> 定稿:[shanks](http://codebuild.me)
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-12
> 3.0
> 翻译: [crayygy](https://github.com/crayygy) 2016-09-12
> 校对: [shanks](http://codebuild.me) 2016-09-27
> 3.0.1shanks2016-11-12
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Closures
> 1.0
> 翻译:[wh1100717](https://github.com/wh1100717)
> 校对:[lyuka](https://github.com/lyuka)
> 2.0
> 翻译+校对:[100mango](https://github.com/100mango)
> 2.1
> 翻译:[100mango](https://github.com/100mango), [magicdict](https://github.com/magicdict)
> 校对:[shanks](http://codebuild.me)
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-12
> 3.0
> 翻译:[Lanford](https://github.com/LanfordCai) 2016-09-19
> 3.0.1shanks2016-11-12
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Enumerations
> 1.0
> 翻译:[yankuangshi](https://github.com/yankuangshi)
> 校对:[shinyzhu](https://github.com/shinyzhu)
> 2.0
> 翻译+校对:[futantan](https://github.com/futantan)
> 2.1
> 翻译:[Channe](https://github.com/Channe)
> 校对:[shanks](http://codebuild.me)
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-13
> 3.0
> 翻译+校对:[shanks](https://codebuild.me) 2016-09-24
> 3.0.1shanks2016-11-12
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Classes And Structures
> 1.0
> 翻译:[JaySurplus](https://github.com/JaySurplus)
> 校对:[sg552](https://github.com/sg552)
> 2.0
> 翻译+校对:[SkyJean](https://github.com/SkyJean)
> 2.1
> 校对:[shanks](http://codebuild.me)2015-10-29
> 2.2
> 校对:[SketchK](https://github.com/SketchK) 2016-05-13
>
> 3.0.1 shanks 2016-11-12
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Properties
> 1.0
> 翻译:[shinyzhu](https://github.com/shinyzhu)
> 校对:[pp-prog](https://github.com/pp-prog) [yangsiy](https://github.com/yangsiy)
> 2.0
> 翻译+校对:[yangsiy](https://github.com/yangsiy)
> 2.1
> 翻译:[buginux](https://github.com/buginux)
> 校对:[shanks](http://codebuild.me)2015-10-29
> 2.2
> 翻译:[saitjr](https://github.com/saitjr)2016-04-11[SketchK](https://github.com/SketchK) 2016-05-13
>
> 3.0.1shanks2016-11-12
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Methods
> 1.0
> 翻译:[pp-prog](https://github.com/pp-prog)
> 校对:[zqp](https://github.com/zqp)
> 2.0
> 翻译+校对:[DianQK](https://github.com/DianQK)
> 2.1
> 翻译:[DianQK](https://github.com/DianQK)[Realank](https://github.com/Realank) 校对:[shanks](http://codebuild.me)2016-01-18
> 2.2
> 校对:[SketchK](https://github.com/SketchK) 2016-05-13
> 3.0.1shanks2016-11-13
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Subscripts
> 1.0
> 翻译:[siemenliu](https://github.com/siemenliu)
> 校对:[zq54zquan](https://github.com/zq54zquan)
> 2.0
> 翻译+校对:[shanks](http://codebuild.me)
> 2.1
> 翻译+校对:[shanks](http://codebuild.me)[Realank](https://github.com/Realank)
> 2.2
> 校对:[SketchK](https://github.com/SketchK) 2016-05-13
> 3.0.1shanks2016-11-13
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Inheritance
> 1.0
> 翻译:[Hawstein](https://github.com/Hawstein)
> 校对:[menlongsheng](https://github.com/menlongsheng)
> 2.02.1
> 翻译+校对:[shanks](http://codebuild.me)
> 2.2
> 校对:[SketchK](https://github.com/SketchK) 2016-05-13
> 3.0.1shanks2016-11-13
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Initialization
> 1.0
> 翻译:[lifedim](https://github.com/lifedim)
> 校对:[lifedim](https://github.com/lifedim)
> 2.0
> 翻译+校对:[chenmingbiao](https://github.com/chenmingbiao)
> 2.1
> 翻译:[Channe](https://github.com/Channe)[Realank](https://github.com/Realank)
> 校对:[shanks](http://codebuild.me)2016-1-23
> 2.2
> 翻译:[pmst](https://github.com/colourful987)
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-14
> 3.0.1shanks2016-11-13
> 3.1
> 翻译:[qhd](https://github.com/qhd) 2017-04-18
> 4.0
> 翻译:[muhlenXi](https://github.com/muhlenxi) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Deinitialization
> 1.0
> 翻译:[bruce0505](https://github.com/bruce0505)
> 校对:[fd5788](https://github.com/fd5788)
> 2.0
> 翻译+校对:[chenmingbiao](https://github.com/chenmingbiao)
> 2.1
> 校对:[shanks](http://codebuild.me)2015-10-31
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-14
> 3.0.1shanks2016-11-13
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Optional Chaining
> 1.0
> 翻译:[Jasonbroker](https://github.com/Jasonbroker)
> 校对:[numbbbbb](https://github.com/numbbbbb), [stanzhai](https://github.com/stanzhai)
> 2.0
> 翻译+校对:[lyojo](https://github.com/lyojo)
> 2.1
> 校对:[shanks](http://codebuild.me)2015-10-31
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-15
> 3.0.1shanks2016-11-13
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Error Handling
> 2.1
> 翻译+校对:[lyojo](https://github.com/lyojo) [ray16897188](https://github.com/ray16897188) 2015-10-23
> 校对:[shanks](http://codebuild.me) 2015-10-24
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-15
> 3.0
> 翻译+校对:[shanks](http://codebuild.me) 2016-09-24
> 3.0.1shanks2016-11-13
> 4.0
> 翻译+校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Type Casting
> 1.0
> 翻译:[xiehurricane](https://github.com/xiehurricane)
> 校对:[happyming](https://github.com/happyming)
> 2.0
> 翻译+校对:[yangsiy](https://github.com/yangsiy)
> 2.1
> 校对:[shanks](http://codebuild.me)2015-11-01
>
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-16
> 3.0.1shanks2016-11-13
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Nested Types
> 1.0
> 翻译:[Lin-H](https://github.com/Lin-H)
> 校对:[shinyzhu](https://github.com/shinyzhu)
> 2.0
> 翻译+校对:[SergioChan](https://github.com/SergioChan)
> 2.1
> 校对:[shanks](http://codebuild.me)2015-11-01
>
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-16
> 3.0.1shanks2016-11-13
> 4.0
> 翻译+校对:[EyreFree](https://www.eyrefree.org/) 2017-10-19
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Extensions
> 1.0
> 翻译:[lyuka](https://github.com/lyuka)
> 校对:[Hawstein](https://github.com/Hawstein)
> 2.0
> 翻译+校对:[shanks](http://codebuild.me)
> 2.1
> 校对:[shanks](http://codebuild.me)
>
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-16
> 3.0.1shanks2016-11-13
> 4.0
> 校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Protocols
> 1.0
> 翻译:[geek5nan](https://github.com/geek5nan)
> 校对:[dabing1022](https://github.com/dabing1022)
> 2.0
> 翻译+校对:[futantan](https://github.com/futantan)
> 2.1
> 翻译:[小铁匠 Linus](https://github.com/kevin833752)
> 校对:[shanks](http://codebuild.me)
>
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK)
>
> 3.0
> 校对:[CMB](https://github.com/chenmingbiao)版本日期2016-09-13
> 3.0.1
> shanks2016-11-13
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Generics
> 1.0
> 翻译:[takalard](https://github.com/takalard)
> 校对:[lifedim](https://github.com/lifedim)
> 2.0
> 翻译+校对: [SergioChan](https://github.com/SergioChan)
> 2.1
> 校对:[shanks](http://codebuild.me)2015-11-01
> 2.2:翻译+校对:[Lanford](https://github.com/LanfordCai)2016-04-08 [SketchK](https://github.com/SketchK) 2016-05-16
> 3.0:翻译+校对:[chenmingjia](https://github.com/chenmingjia)2016-09-12
> 3.0.1shanks2016-11-13
> 3.1:翻译:[qhd](https://github.com/qhd)2017-04-10
> 4.0
> 翻译+校对:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Automatic Reference Counting
> 1.0
> 翻译:[TimothyYe](https://github.com/TimothyYe)
> 校对:[Hawstein](https://github.com/Hawstein)
> 2.0
> 翻译+校对:[Channe](https://github.com/Channe)
> 2.1
> 翻译:[Channe](https://github.com/Channe)
> 校对:[shanks](http://codebuild.me)[Realank](https://github.com/Realank) 2016-01-23
>
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-14
> 3.0.1
> shanks2016-11-13
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Memory Safety
> 4.0
> 翻译:[kemchenj](https://kemchenj.github.io/) 2017-09-21
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Access Control
> 1.0
> 翻译:[JaceFu](http://www.devtalking.com/)
> 校对:[ChildhoodAndy](http://childhood.logdown.com)
> 2.0
> 翻译+校对:[mmoaay](https://github.com/mmoaay)
> 2.1
> 翻译:[Prayer](https://github.com/futantan)
> 校对:[shanks](http://codebuild.me)2015-11-01
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-17
> 3.0.1
> 翻译+校对: shanks2016-11-13
> 4.0
> 翻译kemchenj2017-09-23
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)
## Advanced Operators
> 1.0
> 翻译:[xielingwang](https://github.com/xielingwang)
> 校对:[numbbbbb](https://github.com/numbbbbb)
> 2.0
> 翻译+校对:[buginux](https://github.com/buginux)
> 2.1
> 校对:[shanks](http://codebuild.me)2015-11-01
>
> 2.2
> 翻译+校对:[SketchK](https://github.com/SketchK) 2016-05-17
>
> 3.0
> 翻译+校对:[mmoaay](https://github.com/mmoaay) 2016-09-20
> 3.0.1
> shanks2016-11-13
> 4.1
> 翻译+校对:[mylittleswift](https://github.com/mylittleswift)

6
source/chapter2/chapter2.md Executable file → Normal file
View File

@ -1,3 +1,3 @@
# Swift 教程
本章介绍了 Swift 的各种特性及其使用方法,是全书的核心部分。
# Swift 教程
本章介绍了 Swift 的各种特性及其使用方法,是全书的核心部分。