in Obj-C it was possible to iterate through alphabet with:
for (char x=\'A\'; x<=\'Z\'; x++) {
In Swift this isn\'t possible. Any idea h
This solution works with Swift 3.0, and will either print out the values per OP request:
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".characters.flatMap { print($0) }
Or provide you with an array of letters:
let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".characters.flatMap { $0.description }
In Swift, you can iterate chars on a string like this:
Swift 2
for char in "abcdefghijklmnopqrstuvwxyz".characters {
println(char)
}
Swift 1.2
for char in "abcdefghijklmnopqrstuvwxyz" {
println(char)
}
There might be a better way though.