Skip to content

Instantly share code, notes, and snippets.

View cmlenz's full-sized avatar

Christopher Lenz cmlenz

View GitHub Profile
anonymous
anonymous / gist:3bea53c05336f931bd1d
Created May 5, 2014 15:33
Test email address validation with esoteric email addresses
- (BOOL)isValidEmailAddress:(NSString *)text {
NSError *error = NULL;
NSRange textRange = {0, [text length]};
NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:&error];
if (!detector) {
NSLog(@"Could not instantiate link detector for email validation: %@", error);
return NO;
}
NSTextCheckingResult *result = [detector firstMatchInString:text options:0 range:textRange];