How to insert a WebView into a cocoa app?
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 out开发者_如何学Pythonlet.
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!
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
Did you try to link the WebKit framework, then importing it?
#import "WebKit/WebKit.h"
精彩评论