我已经提到了通过以下链接提供的许多解决方案,但是没有想到。仍然面临这个问题。请参考图片并帮助我。谢谢!
subscript (r: Range<Int>) -> String {
let start = index(startIndex, offsetBy: r.lowerBound)
// let end = <#T##String.CharacterView corresponding to `start`##String.CharacterView#>.index(start, offsetBy: r.upperBound - r.lowerBound)
let end = index(start, offsetBy: r.upperBound - r.lowerBound)
let range: Range<Index> = start..<end
return String(self[range])
}