views:

200

answers:

2

I'm rather new with the whole OSX programming, I wanted to stick a WebView into an empty app. Apparently it isn't as simple as sticking a WebView on a window in interface builder and creating an outlet.

IBOutlet WebView *webView;

It gives me a

expected specifier-qualifier-list before 'WebView'

and when I don't use an outlet, it terminates due to uncaught exception. I'm not too sure what these error messages mean.

Seems it isn't that simple!

+2  A: 

You also need to add the WebKit framework to your target and forward declare WebView or import the header file:

// header file:
@class WebView; // forward declaration sufficient in header
@interface WhatEver ... {
    WebView* webview;
// ...
@property (assign) IBOutlet WebView *webview;
@end

// implementation file:
#import <WebKit/WebView.h> // if you want to do something with the WebView
@implementation WhatEver
@synthesize webview;
// ...
@end
Georg Fritzsche
So far so good. No errors and the app shows, it's just white though. I have noticed I can right click reload..I've got[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com"]]];attached to a button
spamoom
@spamoom: That works just fine for me - are you sure that code is executed?
Georg Fritzsche
I re-created the project and it worked fine.. must have been something funny in that one...
spamoom
A: 

While trying to solve this problem, I came upon this other post that describes that the WebView cannot be layer-backed (and hence any of its superviews cannot be layer-backed as well, I believe, because of the inheritance of being layer-backed from parent views to subviews). Turning off layer backing worked for me!

xtrahotsauce