OC判断用户输入的邮箱地址是否合法的代码

OC判断用户输入的邮箱地址是否合法的代码 

- (BOOL) isEmail: (NSString *) emailAddress {
    NSString *regex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; 
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex]; 

    return [emailTest evaluateWithObject:emailAddress];
}

你可能感兴趣的:(代码)