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: ", ") + "]" + } } ```