【发布时间】:2016-04-11 22:10:27
【问题描述】:
我通过Text Kit Tutorialraywenderlich.com 和线路
edited(.EditedCharacters | .EditedAttributes, range: range, changeInLength: (str as NSString).length - range.length)
产生以下错误:
No '|' candidates produce the expected contextual result type 'NSTextStorageEditActions'
当我将第一个参数更改为:
edited(.EditedCharacters, range: range, changeInLength: (str as NSString).length - range.length)
我也尝试过使用“OR”和“||”没有任何成功。
Swift 2.2 和 iOS 9.2
【问题讨论】:
-
NSTextStorageEditActions现在(似乎本教程是 Swift 2.0 之前的)符合OptionSetType协议,您可以使用类似数组的语法[.OptionA, .OptionB]包含多个选项。例如,在您的示例中,edited([.EditedCharacters, .EditedAttributes], ...。详情请see e.g. this Q&A. -
啊!那行得通 - 谢谢!