我無法將我的Swift 3代碼轉換爲Swift 4.我已經成功翻譯了應用程序中的所有內容,但遇到單行問題代碼:Swift 4:'substring(to :)'已棄用
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」? – Alexander
檢查[此線程](https://stackoverflow.com/q/45562662/6541007)。似乎是重複的。 – OOPer