Swift3 Type 'String' does not conform to protocol 'Sequence'
在Swift3中如果要用for循环遍历字符串String,用以前的方法可能会报标题中的错误,只需要这么做就好了
for character in string.characters {}
字符串倒序也很容易
func reverseString(string: String) -> String {
return String(string.characters.reverse())
}
In Swift 3 reverse()
has been renamed to reversed()
还没有评论,来说两句吧...