I'm trying to display error message for my web view, and I need to know url which is not available, so I implemented delegate method:
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {
[self.addressBar finishLoadingProgressAnimated:YES];
NSLog(@"%@", webView.URL);
[self showErrorPageForURL:error.userInfo[NSErrorFailingURLStringKey]];
}
but NSErrorFailingURLStringKey is deprecated, so how can I get failed URL? WKNavigation's interface is empty. webView.URL == nil at that moment.
You can use NSURLErrorFailingURLStringErrorKey
to replace NSErrorFailingURLStringKey
. If you jump to its definition in Xcode, you will find the below discussion.
This constant supersedes NSErrorFailingURLStringKey, which was deprecated in Mac OS X 10.6. Both constants refer to the same value for backward-compatibility, but this symbol name has a better prefix.