【发布时间】:2017-08-13 17:14:49
【问题描述】:
我在将我的 Swift 3 代码转换为 Swift 4 时遇到问题。我已经成功地翻译了应用程序中的所有其他内容,但是在一行代码中遇到了问题:
cleanURL = cleanURL.substring(to: cleanURL.index(before: cleanURL.endIndex))
我得到的错误是:
ViewController.swift:62:33: 'substring(to:)' is deprecated: Please use String slicing subscript with a 'partial range upto' operator.
【问题讨论】:
-
你确定改变一个变量而不是定义一个新变量有意义吗?如果去掉最后一个符号后 url 是“干净的”,为什么在此之前它还被称为“cleanURL”?
-
检查this thread。似乎是重复的。