1
我正在使用html的解码函数。但是我收到了这个警告。我怎样才能摆脱?Swift 4:substring(with :)'已弃用:请使用String切片下标
func decode(_ entity : String) -> Character? {
if entity.hasPrefix("&#x") || entity.hasPrefix("&#X"){
return decodeNumeric(entity.substring(with: entity.index(entity.startIndex, offsetBy: 3) ..< entity.index(entity.endIndex, offsetBy: -1)), base: 16)
} else if entity.hasPrefix("&#") {
return decodeNumeric(entity.substring(with: entity.index(entity.startIndex, offsetBy: 2) ..< entity.index(entity.endIndex, offsetBy: -1)), base: 10)
} else {
return characterEntities[entity]
}
}
谢谢。
你是否谷歌搜索'substring(with :)'已弃用:请使用字符串切片下标'?那里似乎有很多 –
是的,我偏离了过去。但我没有找到适合我的作品。我不明白为什么我得到这个错误。 – Mayday