Created
March 1, 2014 09:05
-
-
Save KamilLelonek/9287296 to your computer and use it in GitHub Desktop.
String to BOOL extended function
This file contains hidden or 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
- (BOOL) string2bool: (NSString*) aString { | |
NSString *normalizedString = [self normalize: aString]; | |
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern: @"(yes|true|tak|ok|right)" | |
options: NSRegularExpressionCaseInsensitive | |
error: NULL]; | |
return [regex firstMatchInString: normalizedString options: 0 range: NSMakeRange(0, normalizedString.length)]; | |
} | |
// [aString boolValue]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment