代码:
let offset = (index: semiRange.endIndex, offset: 1 – distance(position, semiRange.endIndex))
出错:
/Users/crifan/dev/dev_root/daryun/JianDao/iOS-Client/JianDao/CrifanLib.swift:867:74: ‘distance’ is unavailable: call the ‘distanceTo(end)’ method on the index
如图:
distance is unavailable call the distanceTo(end) method on the index
ios – ‘advancedBy’ API in Swift 2.0 – Stack Overflow
xcode – How to use "distanceTo", "advancedBy" to handle String in Xcode7 beta6 – Stack Overflow
再去参考:
StringExtensionHTML/StringExtensionHTML.swift at master · adela-chang/StringExtensionHTML
改为:
let offset = (index: semiRange.endIndex, offset: 1 – position.distanceTo(semiRange.endIndex))
即可。
转载请注明:在路上 » [已解决]swift代码出错:distance is unavailable call the distanceTo(end) method on the index