Iterate through alphabet in Swift

ios, swift

Solution

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.

Problem

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 how I could do this?

Original source