I can't declare a WebView?

Discussion in 'Mac Programming' started by Yellowstone2012, Jun 27, 2011.

  1. Yellowstone2012 macrumors regular

    Feb 3, 2011
    I have "IBOutlet WebView *theWeb;" and I get the following error: "Unknown type name WebView.

    What does this mean?
  2. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    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.

  3. PatrickCocoa macrumors 6502a

    Dec 2, 2008
    He's right

    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;
  4. Shawnpk, Jun 27, 2011
    Last edited: Jun 28, 2011

    Shawnpk macrumors 6502

    Jan 13, 2011
    Los Angeles, CA
    How about putting a UI in front of WebView to make it UIWebView?
  5. jiminaus macrumors 65816


    Dec 16, 2010
    Because, assuming the post is in the right forum, this isn't iOS. In Mac OS X, it's WebView.
  6. Shawnpk macrumors 6502

    Jan 13, 2011
    Los Angeles, CA
    Didn't catch which forum it was posted in. That's what I get for reading the forums after a 15 hour shift.

Share This Page