判断一个字符串是否为数字
NSCharacterSet *notDigits = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
if ([str rangeOfCharacterFromSet:notDigits].location == NSNotFound)
{ // 是数字 }
else
{ // 不是数字 }
判断一个字符串是否为数字
NSCharacterSet *notDigits = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
if ([str rangeOfCharacterFromSet:notDigits].location == NSNotFound)
{ // 是数字 }
else
{ // 不是数字 }
本文标题:判断字符串是否为数字
本文链接:https://www.haomeiwen.com/subject/yetwrxtx.html
网友评论