キーボードにアルファベット順のレイアウトがないことにまだ気付いていないことをおめでとうございます:)
NSString * str = [@"01234abcdsfsaasgAWEGFWAE" lowercaseString]; // make it a lower case string as you described it not case-sensitive
const char * strUTF8 = [str UTF8String]; // get char* password text for the numerical comparison
BOOL badPassword = NO;
int charIndex = 0;
int badHitCount = 0;
const int len = strlen(strUTF8);
char previousChar = strUTF8[0]; // the app is going to crash here with an empty string
// check the password
while (charIndex < len) {
char currentChar = strUTF8[charIndex++];
if (currentChar - previousChar == 1 && (currentChar >= 57 || currentChar <= 48))
// 57 is the character '9' index at UTF8 table, letters are following this index, some characters are located before 48's '0' character though
badHitCount++;
else
badHitCount = 0;
previousChar = currentChar;
if (badHitCount >= 3) {
badPassword = YES;
break;
}
}
if (badPassword) {
NSLog(@"You are a Bad User !");
} else {
NSLog(@"You are a Good User !");
}