最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]swift代码出错:distance is unavailable call the distanceTo(end) method on the index

iOS crifan 1879浏览 0评论

代码:

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

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
84 queries in 0.221 seconds, using 22.08MB memory