0

I am using the code provided here for the validation Check that an email address is valid on iOS and in this SO answer I am just calling the method like so

-(BOOL) NSStringIsValidEmail:(NSString *)checkString
{
    BOOL stricterFilter = YES;
    NSString *stricterFilterString = @"[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}";
    NSString *laxString = @".+@([A-Za-z0-9]+\\.)+[A-Za-z]{2}[A-Za-z]*";
    NSString *emailRegex = stricterFilter ? stricterFilterString : laxString;
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    return [emailTest evaluateWithObject:checkString];
}

Then within my code like so:

NSString *emailCheck = self.txtEmail.text;
  //prints boolean statement
            NSLog([self NSStringIsValidEmail:emailCheck] ? @"Yes" : @"No");
            //validate email
            if([self NSStringIsValidEmail:emailCheck]) {
                [self alertStatus:@"Please enter a valid email" :@"Register Failed!" :0];
                //enables button on login error
                [btnRegister setEnabled:YES];
                [self callProgressBar:NO];
            }

I added the NSLog to see if I can get an output but it now crashes on the NSLog with a light blue lldb error only. Any help would be appreciated.

Community
  • 1
  • 1
Lion789
  • 4,402
  • 12
  • 58
  • 96
  • what does `NSStringIsValidEmail` return – Brian Tracy Apr 20 '14 at 02:15
  • I added the method above, it returns a Boolean – Lion789 Apr 20 '14 at 02:16
  • Does it fail on all values of self.txtEmail.text? – PCoder123 Apr 20 '14 at 02:17
  • which line is giving the error, and could you include a stack trace / error message? It would greatly help – Brian Tracy Apr 20 '14 at 02:18
  • It fails on this line [self NSStringIsValidEmail:emailCheck] nothing else, email check comes back as the string correctly... not sure how to get a stacktrace as the error is just (lldb) in light blue, self points correctly to the controller I am on as well. – Lion789 Apr 20 '14 at 02:20
  • 2
    I just tested the code with no issues. You don't have a break point set do you? That can cause a lldb in light blue? – PCoder123 Apr 20 '14 at 02:21
  • PCoder123 wow I cannot believe I did not notice that, thanks if you want to write that up ill mark it correct – Lion789 Apr 20 '14 at 02:23

1 Answers1

2

Sometimes a blue lldb message without an error message can indicate that a breakpoint was set. You might want to check to see that all your breakpoints have been removed.

PCoder123
  • 364
  • 2
  • 11