Iterate through alphabet in Swift

前端 未结 8 1942
暗喜
暗喜 2020-12-30 02:23

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

8条回答
  •  太阳男子
    2020-12-30 02:49

    Did you try this one ?

    for var myChar:CChar = 65 ; myChar <= 90 ; ++myChar {
          let x:String = String(format: "%c", myChar)
          println(x)
    }
    

    If you already know the character code

提交回复
热议问题