How do I use loadAlternateHTMLString:baseURL:forUnreachableURL: with webView:didFailProvisionalLoadWithError:forFrame:?
How do I use loadAlternateHTMLString:baseURL:forUnreachableURL: with webView:didFailProvisionalLoadWithError:forFrame:?
- Subject: How do I use loadAlternateHTMLString:baseURL:forUnreachableURL: with webView:didFailProvisionalLoadWithError:forFrame:?
- From: Daryle Walker <email@hidden>
- Date: Tue, 19 Aug 2014 18:45:19 -0400
I’m not sure what parameters you’re supposed to use with the former method, especially within the latter. I got:
> - (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame
> {
> if (frame == sender.mainFrame) { // Ignore notices from sub-frames.
> //[self performSelector:@selector(showError:) withObject:error afterDelay:0.1];
> NSString * const htmlString = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
> "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\""
> "\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"
> "<html xmlns=\"http://www.w3.org/1999/xhtml\">"
> "<head><title>Provisional Load Error</title></head>"
> "<body><dl>"
> "<dt>URL</dt><dd>%@</dd>"
> "<dt>Error</dt><dd>%@</dd>"
> "</dl></body></html>", frame.dataSource.initialRequest.URL, error];
> [frame loadAlternateHTMLString:htmlString baseURL:[NSBundle mainBundle].resourceURL forUnreachableURL:frame.dataSource.initialRequest.URL];
> }
> }
changing from posting a (now commented-out) error alert. I’m trying two cases.
A. Open a new window to the home page (http://www.apple.com), and change the URL to a nonexistent site.
B. Use the “Open Recent” menu to open a file I know I can’t handle. (The menu dates from before I added filters and ripped out the NSDocument architecture to add new files to it. It’s very useful as-is, though.)
I get:
1. The bundle resource directory is in the URL entry field and the command-click window title menu.
2. When I get an error page, it looks like:
> URL
> file:///MY-APP'S-RESOURCE-DIRECTORY
> Error
> Error Domain=WebKitErrorDomain Code=102 "Frame load interrupted" UserInfo=0x608000661d40 {NSErrorFailingURLStringKey=file:///MY-APP'S-RESOURCE-DIRECTORY, NSLocalizedDescription=Frame load interrupted, NSErrorFailingURLKey=file:///MY-APP'S-RESOURCE-DIRECTORY}
with the resource directory in the URL entry field and for the window title bar’s icon and command-click file menu.
Run 1: home page, no Back nor Forward active -> enter bad hostname -> error page like above, Back menu has TWO entries, a “Provisional Load Error” and the home page -> go Back once -> home page, Back menu has home page, Forward menu has Provisional Load Error -> go Back once -> home page, Forward menu has home page and Provisional Load error -> go Forward twice -> error page, except the line under the “URL” title is the home page’s URL -> go Back once -> error page, first edition….
I think I’m supposed to be resetting something between uses or some other misconfiguration is happening. Help.
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden