How to find out if letter is Alphanumeric or Digit in Swift
问题 I want to count the number of letters, digits and special characters in the following string: let phrase = "The final score was 32-31!" I tried: for tempChar in phrase { if (tempChar >= "a" && tempChar <= "z") { letterCounter++ } // etc. but I'm getting errors. I tried all sorts of other variations on this - still getting error - such as: could not find an overload for '<=' that accepts the supplied arguments 回答1: Update for Swift 3: let letters = CharacterSet.letters let digits =