如何将范围int数组转换为字符串数组?
像这个范围int数组:
let data = [Array(1...9), Array(0...59), Array(0...59)]
到字符串数组,如:
let data = [["1", "2", "3",.....], ["0","1", "2", "3",...], ["0","1", "2", "3",...]]
答案 0 :(得分:2)
试试这个
data.map{ $0.map(String.init) }
答案 1 :(得分:0)
let data = [Array(1...9), Array(0...59), Array(0...59)]
var stringArray = Array<Array<String>>()
for array in data {
var subArray = Array<String>()
for item in array {
subArray.append(String(item))
}
stringArray.append(subArray)
}
答案 2 :(得分:-2)
从数组中获取值时,可以尝试这样做。
代码段:
let num = [1, 2, 3]
let data = [num, num, num]
let value = data[0]
for x in value {
print(String(x))
}