Email id verification using Objective C

By | March 29, 2011

Hi,

In order to verify an email address you have entered is valid or not using Objective C, use the following code.

- (BOOL) checkYourMail: (NSString *) myEmail{
      NSString *checkMail= @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}";
      NSPredicate *matchMail = [NSPredicate predicateWithFormat:@"Matching %@", checkMail];
      return [matchMail evaluateWithObject:myEmail];
}

🙂

4 thoughts on “Email id verification using Objective C

  1. dinesh

    Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘Unable to parse the format string “Matching%@”

    iam getting this error when i run ur code

    Reply
    1. dinesh

      can any 1 confirm this code is running fine or with error??

      Reply
  2. Bharath

    NSPredicate * matchMail = [NSPredicate predicateWithFormat:@”SELF MATCHES %@”, checkMail];

    I think it will work….

    Reply

Leave a Reply

Your email address will not be published.