- (BOOL)validateLianxu:(NSString *)passWord{
NSString *last = @"";
int sub = -1;
for (int i = 0; i< passWord.length; i++) {
NSString *str = [passWord substringWithRange:NSMakeRange(i, 1)];
if ([last isEqualToString:@""]) {
//第一次进来
last = str;
continue;
}
if (sub == -1) {
//第二次进来
sub = str.integerValue - last.integerValue;
if (sub>1 ||sub <-1) {
return NO;
}
last = str;
continue;
}
int current_sub = str.integerValue - last.integerValue;
if (current_sub != sub) {
return NO;
}
last = str;
}
return YES;
}
时间: 2024-10-07 06:18:12