Last active
December 27, 2015 15:59
-
-
Save appyaaron/7351690 to your computer and use it in GitHub Desktop.
Check a string for a whitespace by creating an NSArray from an NSString separated by a whitespace. If this count is greater than one, then there is at least 1 whitespace.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSArray *checkPasswordForWhitespace = [password.text componentsSeparatedByString:@" "]; | |
NSLog(@"%@", checkPasswordForWhitespace); | |
if ([checkPasswordForWhitespace count] > 1) { | |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Whitespace" message:@"Please remove the whitespace from your password." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; | |
[alert show]; | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment