1
votes

Hi I just wanted to know how to extract url from webview after loading the web view with the method [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://m.nytimes.com"]]];

In this, I am loading the page with nytimes. When the user navigates to the new page I wan to find out the url the moved page. Is there any way I can find it?

Thanks

1

1 Answers

1
votes

You will need a class to implement the UIWebViewDelegate Protocol, then set an instance of that class to be the delegate of the webview. The method you will want to implement is:

- (void)webViewDidFinishLoad:(UIWebView *)webView

In that delegate method, you can get the url by inspecting the request property of the web view.

Edit: Changed the recommended delegate method due to Anomie's comment pointing out my failure to see the request propery of UIWebView.