SwiftDeveloper SwiftDeveloper - 1 year ago 104
Swift Question

How to add new array objects with int value

Hello i have

array in my project ;

var firstArray = [FirstArray]()

Also i have another array in my view;

var TypeId = [""]

I want to add
objects into
array size of

For example : firstArray.count = 7 , TypeId Array output must be = ["1","1","1","1","1","1","1"]

Also how to get TypeId array values to string inside like

Thank you !

Answer Source

If you want typeID array contains the number of element equal to firstArray you can use map like this.

var typeID = firstArray.map { _ in String("1") }

Edit : Join typeID array elements by ,

let typeIDString = typeID.joinWithSeparator(",")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download