From 80e357c01c5d41b8c9af40272e5a312493f1cdc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=8E=E4=BB=8A=E4=BB=A5=E5=90=8E?= <949478479@qq.com> Date: Fri, 17 Feb 2017 10:11:17 +0800 Subject: [PATCH] Update 22_Protocols.md (#685) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改正示例代码中的两处错误 --- source/chapter2/22_Protocols.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/chapter2/22_Protocols.md b/source/chapter2/22_Protocols.md index 519c24ca..8498c30b 100644 --- a/source/chapter2/22_Protocols.md +++ b/source/chapter2/22_Protocols.md @@ -737,8 +737,8 @@ for object in objects { ```swift @objc protocol CounterDataSource { - optional func incrementForCount(count: Int) -> Int - optional var fixedIncrement: Int { get } + @objc optional func incrementForCount(count: Int) -> Int + @objc optional var fixedIncrement: Int { get } } ``` @@ -886,11 +886,11 @@ extension PrettyTextRepresentable { 例如,你可以扩展 `CollectionType` 协议,但是只适用于集合中的元素遵循了 `TextRepresentable` 协议的情况: ```swift -extension CollectionType where Generator.Element: TextRepresentable { - var textualDescription: String { - let itemsAsText = self.map { $0.textualDescription } - return "[" + itemsAsText.joinWithSeparator(", ") + "]" - } +extension Collection where Iterator.Element: TextRepresentable { + var textualDescription: String { + let itemsAsText = self.map { $0.textualDescription } + return "[" + itemsAsText.joined(separator: ", ") + "]" + } } ```