在Swift3中如果要用for循环遍历字符串String,用以前的方法可能会报标题中的错误,只需要这么做就好了
@H_502_12@for character in string.characters {}
字符串倒序也很容易
func reverseString(string: String) -> String { return String(string.characters.reverse()) }
In Swift 3
reverse()
has been renamed toreversed()
原文链接:https://www.f2er.com/swift/322629.html