I am trying to split an Int into its individual digits, e.g. 3489 to 3 4 8 9, and then I want to put the digits in an Int array.
I have already tried putting the number into a string and then iterating over each digit, but it doesn't work:
var number = "123456"
var array = [Int]()
for digit in number {
array.append(digit)
}
Any ideas?
See Question&Answers more detail:os