Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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!

like image 847
spamoom Avatar asked Dec 18 '25 18:12

spamoom


2 Answers

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
like image 149
Georg Fritzsche Avatar answered Dec 20 '25 10:12

Georg Fritzsche


Did you try to link the WebKit framework, then importing it?

#import "WebKit/WebKit.h"
like image 28
gabr10 Avatar answered Dec 20 '25 09:12

gabr10



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!