0

I'm trying to detect if a specific url is being loaded in a uiwebview and if so redirect the webview to a different url. So far I've got the following code which should seem to work for me but no luck so far, anyone know what I'm doing wrong:

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{

    if(request.URL == [NSURL URLWithString:@"https://cheese.com/"])
    {
        NSURL *url = [NSURL URLWithString:@"https://example.com/"];
        [self.webView loadRequest:[NSURLRequest requestWithURL:url]];

    } else {

    }

    return  YES;
}
user1419810
  • 836
  • 1
  • 16
  • 29

1 Answers1

1
if([request.URL.relativeString isEqualToString:@"https://cheese.com/"]) {

}
An Kit
  • 308
  • 1
  • 2
  • 9