[Swift]字符串遍历效率记录

 for theChar in s.characters {
  //something
}

效率:

1.png
for i in 0..<s.characters.count {
  let theChar = s[s.index(s.startIndex, offsetBy: i)]
       //something     
}

效率:

2.png

推荐阅读更多精彩内容