int数组转化成string数组(swift)

前端之家收集整理的这篇文章主要介绍了int数组转化成string数组(swift)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

int数组转化成string数组(swift)

let nums = [1,2,3,4,5,6,7]
var strs = [String]()
for var i = 0; i < nums.count; ++i {
    strs.append(String(nums[i]))
}
let nums = [1,7]
let strs = nums.map(String.init)
  • result:
["1","2","3","4","5","6","7"]

猜你在找的Swift相关文章