I create a range of in from 1-100 doing this:
let array = [Int](1...10)
Now how do I convert that into a String array as I need it for UIPickerView
Thanks in advance.
var arr = [1,2,3]
let strArr = arr.map{String($0)}
OR in picker you may return the component title like this
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {
return "\(arr[row])"
}
If it is just a sequence of strings "1", "2", .. you can simply get it using map:
let model = array.map { "\($0)" }
If you are looking for spelled out numbers, such as "one", "two", ..., use number formatter:
let numberFormatter: NumberFormatter = NumberFormatter()
numberFormatter.numberStyle = NumberFormatter.Style.spellOut
let model = array.map { numberFormatter.string(from: NSNumber(value: $0)) ?? "" }