PDA

View Full Version : I can't declare a WebView?




Yellowstone2012
Jun 27, 2011, 07:55 PM
I have "IBOutlet WebView *theWeb;" and I get the following error: "Unknown type name WebView.

What does this mean?



chown33
Jun 27, 2011, 08:01 PM
What does this mean?

My first guess: you haven't imported WebKit:
#import <WebKit/WebKit.h>

That's just a guess, though, since you haven't posted enough code to say for sure.

If you have the import, then maybe you forgot to add the framework to your project.

http://www.cocoadev.com/index.pl?WebKit

PatrickCocoa
Jun 27, 2011, 10:27 PM
chown33 is right (whatever happened to chowns 1 - 32?). A few other notes (I don't know how far along you are in your Cocoa journey):

IBOutlet just tells Xcode that you may want to hook up your object to something in a NIB file.

WebView is the name of that class that your object is an instance of. Per chown33, Xcode needs to know what a WebView is by including it your list of frameworks (normally only the UIKit and Foundation frameworks are included by default), and then you must import that framework (WebKit) into the .h file you're working on.

* means that the next variable is really a pointer to an object.

theWeb is the name of the object. You'll use this name later on to create and display things, probably web pages. You can name this anything, Cocoa convention is to start with a lower case and use upper case for each succeeding word. For instance you could have two objects:

IBOutlet WebView *mySecretPornWebPage;
IBOutlet WebView *myAdorableKittensWebPage;

Shawnpk
Jun 27, 2011, 11:49 PM
I have "IBOutlet WebView *theWeb;" and I get the following error: "Unknown type name WebView.

What does this mean?

How about putting a UI in front of WebView to make it UIWebView?

jiminaus
Jun 28, 2011, 02:25 AM
How about putting a UI in front of WebView to make it UIWebView?

Because, assuming the post is in the right forum, this isn't iOS. In Mac OS X, it's WebView.

Shawnpk
Jun 28, 2011, 08:40 AM
Because, assuming the post is in the right forum, this isn't iOS. In Mac OS X, it's WebView.

Didn't catch which forum it was posted in. That's what I get for reading the forums after a 15 hour shift.