只要在 textViewDidChange 方法中先对 text 进行判断一下就 OK 了
-(BOOL)isSudoku:(NSString *)str{
NSString *other = @"➋➌➍➎➏➐➑➒";
NSString *lastStr = [str substringFromIndex:str.length-1];
if (![other containsString:lastStr]) {
return NO;
}
unsigned long len=lastStr.length;
for(int i=0; i<len; i++)
{
unichar a=[lastStr characterAtIndex:i];
if(!((isalpha(a))
||(isalnum(a))
||((a=='_') || (a == '-'))
||((a >= 0x4e00 && a <= 0x9fa6))
||([other rangeOfString:lastStr].location != NSNotFound)
))
return NO;
}
return YES;
}
网友评论