这是我的快速3代码:
extension String {
func nsRange(from range: Range<Index>) -> NSRange {
let lower = UTF16View.Index(range.lowerBound, within: utf16)
let upper = UTF16View.Index(range.upperBound, within: utf16)
return NSRange(location: utf16.startIndex.distance(to: lower), length: lower!.distance(to: upper))
}
}
当我迁移到swift 4时,它给了我错误距离(到:)不可用
任何解决方案