//
+(BOOL)stringIsNumber:(NSString *)str
{
NSData *myD = [str dataUsingEncoding:NSUTF8StringEncoding];
Byte *bytes = (Byte *)[myD bytes];
//下面是Byte 转换为16进制。
for(int i=0;i<[myD length];i++)
{
NSInteger hex = bytes[i]&0xff;
if (hex < 48 || hex > 57)
{
return NO;
break;
}
}
return YES;
}
网友评论