📌  相关文章
📜  如何在 siwft 中将 index(_rawBits:) 转换为 int - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:04.005000             🧑  作者: Mango

代码示例1
//swift 4-5
let text = "abc"
let index2 = text.index(text.startIndex, offsetBy: 2) //will call succ 2 times
let lastChar: Character = text[index2] //now we can index!

let characterIndex2 = text.index(text.startIndex, offsetBy: 2)
let lastChar2 = text[characterIndex2] //will do the same as above

let range: Range = text.range(of: "b")!
let index: Int = text.distance(from: text.startIndex, to: range.lowerBound)