I'm using this project to get me started with the WebKit framework under OSX.
It loads resources locally, and I've been able to get it to work. However, when I alter awakeFromNib to load from a URL string like http://www.example.com/index.html
It doesn't work, the view is blank, even though this is a valid URL.
Original:
- (void)awakeFromNib {
WebPreferences *prefs = [webView preferences];
[prefs _setLocalStorageDatabasePath:@"~/Library/WebViewExample/LocalStorage"];
NSString *resourcesPath = [[NSBundle mainBundle] resourcePath];
NSString *htmlPath = [resourcesPath stringByAppendingString:@"/htdocs/640x480_naked.html"];
[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:htmlPath]]];
}
Modified for external URL:
- (void)awakeFromNib {
WebPreferences *prefs = [webView preferences];
[prefs _setLocalStorageDatabasePath:@"/tmp"];
NSString *urlText = @"http://www.example.com/index.html";
[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlText]]];
}
What could be wrong?