标签: string swift2
我有一个字符串var a = "abcd",我希望获得一个单字符串["a", "b", "c", "d"]的数组。我试过了Array(a.characters),但这只给了我[Character]而不是[String]。怎么做?
var a = "abcd"
["a", "b", "c", "d"]
Array(a.characters)
[Character]
[String]
答案 0 :(得分:2)
var str = "abcd" let strArr = str.characters.map { String($0) }