title: textfield verify method obj c
body: <p>I have a view with 2 textfields fields and a button.</p>
  
  <p>in the "clickOnDoneButton" function I have to perform the following function: I have to verify that the pin inserted in the first textfield with the second textfield.
  I have to verify the pin with the "checkValidityPin" function which is correct, I cannot implement it correctly.
  the logic to be implemented is: I check the first "pin" entered with checkValidityPin, if it is correct I check it with the second "pin" which must be the same.</p>
  
  <p>I think I got lost in the function I can no longer go on ..</p>
  
  <pre><code>    @property (nonatomic, strong) id delegate;
  @property (nonatomic, weak) IBOutlet UIButton *confirmButton;
  @property (weak, nonatomic) IBOutlet InputTextView *insertPin;
  @property (weak, nonatomic) IBOutlet InputTextView *verifyPin;
  @property (nonatomic, strong) NSString* stringInserted;
  
  - (IBAction) clickOnDoneButton:(id)sender;
  
  
  - (IBAction) clickOnDoneButton:(id)sender{
          [[NSOperationQueue mainQueue] addOperationWithBlock:^{
              NSString * errorMessage = @"";
  
              if(!self.insertPin || [self.insertPin isEqual:[NSString string]]) {
                  self.insertPin = self.stringInserted;
  //                [self.insertPin redrawWithInputLength:0];
      //            self.titleLabel.text = NSLocalizedString(@"INSERT_NEW_PIN", nil);
  //                [self setTextAnimated:NSLocalizedString(@"INSERT_NEW_PIN", nil)];
  //                self.keyboard.confirButton.enabled = NO;
                  self.stringInserted = [NSString string];
              } else if(!self.verifyPin || [self.verifyPin isEqual:[NSString string]]) {
                  if (![self.stringInserted isEqualToString:self.insertPin]){
                      if([self checkValidityPin:self.stringInserted]){
                          self.verifyPin = _stringInserted;
  
  //                        [self.fieldView redrawWithInputLength:0];
      //                    self.titleLabel.text = NSLocalizedString(@"REINSERT_NEW_PIN", nil);
  //                        [self setTextAnimated:NSLocalizedString(@"REINSERT_NEW_PIN", nil)];
  //                        self.keyboard.confirButton.enabled = NO;
                          self.stringInserted = [NSString string];
                          NSLog(@"TEST4");
                      }
                      else{
                          errorMessage = NSLocalizedString(@"WRONG_PIN_FORMAT", nil);
                          NSLog(@"TEST2");
  
                      }
                  } else {
                      errorMessage = NSLocalizedString(@"NEW_PIN_EQUALS_OLD", nil);
                      NSLog(@"TEST3");
  
                  }
              }
  
              else if([self.verifyPin isEqual:self.stringInserted]) {
                  NSLog(@"TEST");
              }
              else {
  //                [self.fieldView redrawWithInputLength:0];
                  self.stringInserted = [NSString string];
                  self.insertPin = nil;
                  self.verifyPin = nil;
                  NSLog(@"TEST1");
  
  //                [self setTextAnimated:NSLocalizedString(@"INSERT_OLD_PIN", nil)];
                  //            self.keyboard.confirButton.enabled = NO;
                  errorMessage = NSLocalizedString(@"PIN_NOT_EQUALS", nil);
              }
  
              //Show Error
  //            if([errorMessage length]&gt;0){
  //                [self showError:errorMessage];
  //            }
  
          }];
  }
  
  -(BOOL) checkValidityPin:(NSString*)pin{
      NSString *regex1 = @"^(01234|12345|23456|34567|45678|56789)$";
      NSString *regex2 = @"^(98765|87654|76543|65432|54321|43210)$";
      NSString *regex3 = @"^([0-9])\\1*$";
  
      BOOL testPassed1 = [PRUtility validateRegularExpression:regex1 forString:pin];
      BOOL testPassed2 = [PRUtility validateRegularExpression:regex2 forString:pin];
      BOOL testPassed3 = [PRUtility validateRegularExpression:regex3 forString:pin];
  
      return !(testPassed1 || testPassed2 || testPassed3);
  }
  </code></pre>