How does iOS determine whether a string is a Chinese character or a letter?
// If the entered nickname is a letter, determine whether it is qualified
If (self. nickNameText ){
For (int I = 0; I
Nsange range = NSMakeRange (I, 1 );
NSString * subString = [self. nickNameTextsubstringWithRange: range];
Const char * cString = [subStringUTF8String];
If (strlen (cString) = 3)
{
NSLog (@ "nicknames are Chinese characters ");
If (self. nickNameText. length <2 | self. nickNameText. length> 8 ){
UIAlertView * alertView = [[UIAlertViewalloc] initWithTitle: @ "do not enter two or more" message: @ "the nickname format you entered is incorrect. Please enter" delegate: selfcancelButtonTitle: @ "cancel" otherButtonTitles: @ "OK", nil];
[AlertViewshow];
Return;
}
} Elseif (strlen (cString) = 1)
{
NSLog (@ "nickname is a letter ");
If (self. nickNameText. length <4 | self. nickNameText. length> 16 ){
UIAlertView * alertView = [[UIAlertViewalloc] initWithTitle: @ "do not enter four or more" message: @ "Your entered nickname format is incorrect" delegate: selfcancelButtonTitle: @ "cancel" otherButtonTitles: @ "OK", nil];
[AlertViewshow];
Return;
}
}
}
}