Reputation: 1288
I want to get the URL of my webview. I searched for solutions, the only one was
NSString *myUrl = webView.request.URL.absoluteString ;
This is not working anymore ! it's giving me (null) as a result.
I'm developing for iOS 5.
Upvotes: 3
Views: 2844
Reputation: 280
There is nothing wrong with the absoluteString method, but webView.request is probably nil as well. It seems that the request property of UIWebView is nil until the request has been loaded.
If it's not a problem to wait for the webview to complete the loading, use the delegate method -(void)webViewDidFinishLoad:(UIWebView *)webView
to get your URL. If you need it before that, you should get it from another place in your code (for example, where the webview's loadRequest is being called).
Upvotes: 3