From 9ab6f2670fae5e4e72e7dc828b983b99082b7c78 Mon Sep 17 00:00:00 2001 From: Hanlei Qin Date: Thu, 22 Oct 2015 11:11:58 +0800 Subject: [PATCH 1/4] Update 02_a_swift_tour.md typo fixed. --- source/chapter1/02_a_swift_tour.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/chapter1/02_a_swift_tour.md b/source/chapter1/02_a_swift_tour.md index dcfb2232..823358e2 100755 --- a/source/chapter1/02_a_swift_tour.md +++ b/source/chapter1/02_a_swift_tour.md @@ -233,7 +233,7 @@ print(secondForLoop) func greet(name: String, day: String) -> String { return "Hello \(name), today is \(day)." } -greet("Bob", "Tuesday") +greet("Bob", day: "Tuesday") ``` > 练习: From 7454df6159f817e3a551a3e55355d1ab3cca59bc Mon Sep 17 00:00:00 2001 From: Zee Ma Date: Thu, 22 Oct 2015 20:08:56 +0800 Subject: [PATCH 2/4] put the code to anterior position correct code exist in the wrong place, it will lead a compiling warning --- source/chapter2/14_Initialization.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/chapter2/14_Initialization.md b/source/chapter2/14_Initialization.md index e79a04a9..31a9c054 100755 --- a/source/chapter2/14_Initialization.md +++ b/source/chapter2/14_Initialization.md @@ -837,9 +837,10 @@ if let bowTie = Product(name: "bow tie") { class CartItem: Product { let quantity: Int! init?(name: String, quantity: Int) { + self.quantity = quantity super.init(name: name) if quantity < 1 { return nil } - self.quantity = quantity + } } ``` From b9c3ee766f3d9fe19e911fa8352c63959e107c08 Mon Sep 17 00:00:00 2001 From: Qing Date: Fri, 23 Oct 2015 07:52:09 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8E=92=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/chapter2/03_Strings_and_Characters.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/source/chapter2/03_Strings_and_Characters.md b/source/chapter2/03_Strings_and_Characters.md index 65c635c3..fabc81e3 100755 --- a/source/chapter2/03_Strings_and_Characters.md +++ b/source/chapter2/03_Strings_and_Characters.md @@ -25,17 +25,15 @@ `String`是例如"hello, world","albatross"这样的有序的`Character`(字符)类型的值的集合。通过`String`类型来表示。 -一个`String`的内容可以用变量的方式读取,它包括一个`Character`值的集合。 +一个`String`的内容可以用变量的方式读取,它包括一个`Character`值的集合。 创建和操作字符串的语法与 C 语言中字符串操作相似,轻量并且易读。 -字符串连接操作只需要简单地通过`+`符号将两个字符串相连即可。 -与 Swift 中其他值一样,能否更改字符串的值,取决于其被定义为常量还是变量。你也可以在字符串内插过程中使用字符串插入常量、变量、字面量表达成更长的字符串,这样可以很容易的创建自定义的字符串值,进行展示、存储以及打印。 +字符串连接操作只需要简单地通过`+`符号将两个字符串相连即可。与 Swift 中其他值一样,能否更改字符串的值,取决于其被定义为常量还是变量。你也可以在字符串内插过程中使用字符串插入常量、变量、字面量表达成更长的字符串,这样可以很容易的创建自定义的字符串值,进行展示、存储以及打印。 尽管语法简易,但`String`类型是一种快速、现代化的字符串实现。 -每一个字符串都是由编码无关的 Unicode 字符组成,并支持访问字符的多种 Unicode 表示形式(representations)。 -你也可以在常量、变量、字面量和表达式中进行字符串插值操作,这可以帮助你轻松创建用于展示、存储和打印的自定义字符串。 +每一个字符串都是由编码无关的 Unicode 字符组成,并支持访问字符的多种 Unicode 表示形式(representations)。你也可以在常量、变量、字面量和表达式中进行字符串插值操作,这可以帮助你轻松创建用于展示、存储和打印的自定义字符串。 -> 注意: +> 注意: > Swift 的`String`类型与 Foundation `NSString`类进行了无缝桥接。就像 [`AnyObject`类型](./19_Type_Casting.html#anyobject) 中提到的一样,在使用 Cocoa 中的 Foundation 框架时,您可以将创建的任何字符串的值转换成`NSString`,并调用任意的`NSString` API。您也可以在任意要求传入`NSString`实例作为参数的 API 中用`String`类型的值代替。 -> 更多关于在 Foundation 和 Cocoa 中使用`String`的信息请查看 *[Using Swift with Cocoa and Objective-C (Swift 2)](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/index.html#//apple_ref/doc/uid/TP40014216)*。 +> 更多关于在 Foundation 和 Cocoa 中使用`String`的信息请查看 *[Using Swift with Cocoa and Objective-C (Swift 2.1)](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/index.html#//apple_ref/doc/uid/TP40014216)*。 From fd3b28a3342effb871e8d4a403218b2f728ef0bb Mon Sep 17 00:00:00 2001 From: Qing Date: Fri, 23 Oct 2015 08:03:01 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8F=92=E5=80=BC?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=20For=202.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/chapter2/03_Strings_and_Characters.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/chapter2/03_Strings_and_Characters.md b/source/chapter2/03_Strings_and_Characters.md index fabc81e3..76ad2027 100755 --- a/source/chapter2/03_Strings_and_Characters.md +++ b/source/chapter2/03_Strings_and_Characters.md @@ -188,8 +188,8 @@ let message = "\(multiplier) times 2.5 is \(Double(multiplier) * 2.5)" 该表达式计算`Double(multiplier) * 2.5`的值并将结果 (`7.5`) 插入到字符串中。 在这个例子中,表达式写为`\(Double(multiplier) * 2.5)`并包含在字符串字面量中。 -> 注意: -> 插值字符串中写在括号中的表达式不能包含非转义双引号 (`"`) 和反斜杠 (`\`),并且不能包含回车或换行符。 +> 注意: +> 插值字符串中写在括号中的表达式不能包含非转义反斜杠 (`\`),并且不能包含回车或换行符。不过,插值字符串可以包含其他字面量。