I have an array:
var numberArray = [1,2,3]
I want to convert this into a string and put it into a label text:
label.text = "123"
I've already tried for loops / other things online. Thanks :)
I have an array:
var numberArray = [1,2,3]
I want to convert this into a string and put it into a label text:
label.text = "123"
I've already tried for loops / other things online. Thanks :)
You can simply do this using higher order functions Map
and Reduce
label.text = numberArray.map{ String($0) }.reduce("", +)
Or you can use joined() as well
label.text = numberArray.map{String($0)}.joined()
You can also use map this way
label.text = numberArray.map(String.init).joined()