- (void)click:(UIButton *)sender{
NSString *str = self.textField.text;
BOOL b = [self hasChinese:str];
if (b) {
NSLog(@"中文");
}else{
NSLog(@"----");
}
}
/**
检测是否含有中文
*/
- (BOOL)hasChinese:(NSString *)str {
BOOL c = false;
for(int i=0; i< [str length];i++){
int a = [str characterAtIndex:i];
if( a > 0x4e00 && a < 0x9fff)
{
c = true;
}else{
c = false;
return c;
}
}
return c;
}