Guest User

Untitled

a guest
Jan 15th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
  2. static NSString *regexp = @"^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9-]*[a-zA-Z0-9])[.])+([A-Za-z]|[A-Za-z][A-Za-z0-9-]*[A-Za-z0-9])$";
  3. NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regexp];
  4.  
  5. if ([predicate evaluateWithObject:request.URL.host]) {
  6. [[UIApplication sharedApplication] openURL:request.URL];
  7. return NO;
  8. } else {
  9. return YES;
  10. }
  11. }
Add Comment
Please, Sign In to add comment