// If the input nickname is a letter, determine whether it is qualified
if (self.) Nicknametext) {
for (int i=0; i<self.) Nicknametext. length; i++) {
nsrange range=nsmakerange(i,1);
nsstring *substring=[self. Nicknametextsubstringwithrange: Range];
Const Char *cstring=[substringutf8string];
if (strlen(cString) = =3)
{
NSLog (@ " nickname is kanji ");
if (self.) Nicknametext. length<2| | Self. Nicknametext. length>8) {
Uialertview*alertview=[[UialertviewAlloc]Initwithtitle:@"do not enter less than2one or more than8a"Message:@"the nickname you entered is in the wrong format, please re-enter"Delegate: SelfCancelbuttontitle:@"Cancel"Otherbuttontitles:@"Determine",Nil];
[Alertviewshow];
return;
}
}Elseif(strlen(cString) = =1)
{
NSLog (@ " nickname is letter ");
if (self.) Nicknametext. length<4| | Self. Nicknametext. length>) {
Uialertview*alertview=[[UialertviewAlloc]Initwithtitle:@"do not enter less than4one or more than -a"Message:@"the nickname you entered is in the wrong format"Delegate: SelfCancelbuttontitle:@"Cancel"Otherbuttontitles:@"Determine",Nil];
[Alertviewshow];
return;
}
}
}
}
How does IOS tell if a string is a Chinese character or a letter