Update 22_Protocols.md (#685)

改正示例代码中的两处错误
This commit is contained in:
从今以后
2017-02-17 10:11:17 +08:00
committed by 安正超
parent ef7dc20a57
commit 80e357c01c

View File

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