What is the replacement for isDigit() for characters in Swift?

前端 未结 6 1149
失恋的感觉
失恋的感觉 2020-12-29 03:58

As mentioned in this post, before Xcode 6 Beta 4, one could use c.isDigit() and c.isAlpha() to find if c : Character was a digit or al

6条回答
  •  不知归路
    2020-12-29 04:48

    For a single character:

    CharacterSet.decimalDigits.contains(string.unicodeScalars.first!)
    

提交回复
热议问题