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

2017-02-07  本文已影响81人  PlutoMa
 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
上一篇下一篇

猜你喜欢

热点阅读