In the AppDelegate.h file, add this line below the line #import <Cocoa/Cocoa.h> :
#import <WebKit/WebKit.h>
and add this line below the line @property (assign) IBOutlet NSWindow *window; :
@property (assign) IBOutlet WebView *webView;
Select the MainMenu.xib file.
Open the window inside it, then drag the WebView from the object library browser into the window. Align and size it.
There should be an icon representing your AppController object to the left of your user interface layout. Control the drag and drop from it to the WebView inside your window. (Do not drag the File Owner icon!) Release the mouse button. A context menu WebView containing the word WebView . Select it.
Add the WebKit.framework framework to your project. Right-click the Frameworks folder in the resource list on the left side of the Xcode window. Select "Add files to" <your project name> "... and select the structure using this path: /System/Library/Frameworks/WebKit.framework .
Select the AppDelegate.m file.
In your -applicationDidFinishLaunching: method, replace the comment with the following code:
Create and run. When the window appears, you will see that it loads the web page specified in the URL.
A few final words:
I see that you are new here. What I just did, in the context of Stack Overflow, is to give you a present. You need to try looking a bit hard on the Internet. I found two myself, but since they are a bit old (and the development tools look different), I proceeded to this answer. I want you to promise that you will work harder to find the answers yourself. A great place to start is to read Apple's excellent documentation .
trudyscousin
source share