我有一个iphone应用程序,我想在其中检查字符串值是否介于0到9之间。如果是这样,我想做其他事情。有人知道怎么做这个吗?
最佳答案
if (string.length == 1 && [string characterAtIndex:0] >= '0' && [string characterAtIndex:0] <= '9') {
// do something
}
这将检查字符串是否正好是1个字符长,并且该字符是0、1、2、3、4、5、6、7、8或9。
关于iphone - 如何检查字符串值是否从0到9?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11901449/