This is a perfect bit of code for delimited strings. It is included in Foundation.

import Foundation

let numbers = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10"
let array = numbers.components(separatedBy: ", ")

Output

["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]

Leave a Reply