Swift 字符串转数组:
let str = "I am FlyElephant"
let array = str.components(separatedBy:" ")
print("字符串转数组:\(array)")
Swift 数组转字符串:
let data = [1, 2, 3, 4, 5]
let dataStr = data.map(String.init)
let result = dataStr.joined(separator: ",")
print("数组转字符串:\(result)")
网友评论
let result = dataStr.joined(separator: ",")报错