title: Check if function returns true Objective-C
body: <p>I am wanting to check that when a function returns a true value then <code>NSLog(@"hello!!!");</code> Just to confirm, I wish to check that <code>validUrl</code> returns <code>true</code>. I have declared the controller that it is inside, and this is the complete code: </p>
  
  <pre><code>NewInAppWebViewController *webViewController = [[NewInAppWebViewController alloc] init];
  
          if([webViewController validUrl:(NSURL *)url] == true) {
              NSLog(@"hello!!!");
          }
          else
          {
              [self showAlertForExternalURL:url];
          }
  </code></pre>
  
  <p>Below is the function:</p>
  
  <pre><code>- (BOOL)validUrl:(NSURL*)url {
      NSString *stringURL = [url absoluteString];
  
      if([stringURL length]==0){
          return false;
      }
  
      NSString *regExPattern = @"www-(test|testing[a-z]|newtest)\.testerer\.com";
  
      NSRegularExpression *regEx = [[NSRegularExpression alloc] initWithPattern:regExPattern options:NSRegularExpressionCaseInsensitive error:nil];
      NSUInteger regExMatches = [regEx numberOfMatchesInString:stringURL options:0 range:NSMakeRange(0, [stringURL length])];
  
      NSLog(@"%i", regExMatches);
      if (regExMatches == 0) {
          return false;
      } else {
          return true;
      }
  }
  </code></pre>