我是Swift中的新手,我有简单的代码,该代码将字符串从末尾切成特殊字符“ $ 2F”,并返回切断的字符串:
let index2 = favUrlString.range(of: "%2F", options: .backwards)?.lowerBound
favUrlString = index2.map(favUrlString.substring(to:))!
如何将这段代码更新为Swift 5?
答案 0 :(得分:-1)
使用String Slicing
代替Substring
。像下面一样
let yourString = "dummy string"
yourString[5..<yourString.count] // string