Hello everyone i need some help. I’m trying to make an application for mac in Xcode 4.0 and i want it to display a webpage on launch i have already added the webkit framework and have got some code but its not working. the code is below
The app delegate.m file
#import "AppDelegate.h"
#import <WebKit/WebKit.h>
@implementation AppDelegate
@synthesize window = _window;
@synthesize WebView;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSString *urlAddress = @"http://www.google.com/";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[[WebView mainFrame] LoadRequest:requestObj];
}
@end
and the app delegate.h file
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet WebView *WebView;
@interface myAppDelegate : NSObject <NSApplicationDelegate> {
WebView *myWebView;
}
@property (retain, nonatomic) IBOutlet WebView *myWebView;
@end
If anyone can help please respond asap thanks guys!
hmm, i’m assuming that code isn’t compiling? (it shouldn’t be! 🙂 ). the .h should look something like:
and the .m:
this assumes you’ve connected the webview in the .xib with the myWebView property.