2017-05-04 111 views
2

我知道,如果我想的Int秒的数组转换为String,我这样做:转换int数组以逗号分隔字符串

[0,1,1,0].map{"\($0)"}.reduce(""){$0+$1} 

,但我想不出我将如何转换的Int s到一个逗号阵列分离String

+0

通过使用joinWithSeparator功能,你可以这样做:https://开头iosdevcenters。 blogspot.com/2016/04/array-in-swift.html –

回答

19

那么你可以不喜欢它:

let formattedArray = ([0,1,1,0].map{String($0)}).joined(separator: ",") 
+0

VAR stringIds = “” 如果让tmpList = self.userList { stringIds =(tmpList.map {$ 0.id})。图{字符串( $(0)}。joined(separator:“,”) } 用户列表是我的自定义对象数组。 –

相关问题