以下代码来源于网络
//判断字符串中是否含有某个字符串
+ (BOOL)isHaveSpaceInString:(NSString *)string{
NSRange _range = [string rangeOfString:@" "];
if (_range.location != NSNotFound) {
return YES;
}else {
return NO;
}
}
//判断字符串中是否含有中文
+ (BOOL)isHaveChineseInString:(NSString *)string{
for(NSInteger i = 0; i < [string length]; i++){
int a = [string characterAtIndex:i];
if (a > 0x4e00 && a < 0x9fff) {
return YES;
}
}
return NO;
}
//判断字符串是否全部为数字
+ (BOOL)isAllNum:(NSString *)string{
unichar c;
for (int i=0; i
c=[string characterAtIndex:i];
if (!isdigit(c)) {
return NO;
}
}
return YES;
}