Kevin G
Kevin G

Reputation: 2455

Xcode Webview Open Url

I'm trying to develop a web browser that will display a website after the launch . I already red the articles and with i cant seem to get it to work with this code .

NSURL*url=[NSURL URLWithString:@"http://www.google.com"];
NSURLRequest*request=[NSURLRequest requestWithURL:url];
[[webview mainFrame] loadRequest:request];

I'm using the cocoa and the Webkit Framework .

Upvotes: 1

Views: 7364

Answers (2)

jediob1
jediob1

Reputation: 56

Try this:

- (void)applicationDidFinishLaunching:(NSNotification *)notification{
    NSString *urlText = @"http://google.com";
    [[myWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlText]]];
    return;
}

if that doesn't work, try this:

- (void)awakeFromNib{
    NSString *urlText = @"http://google.com";
    [[myWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlText]]];
    return;
}

Good luck! tell me if this works!

Upvotes: 3

rishi
rishi

Reputation: 11839

Use -

[webview loadRequest:request];

Upvotes: 0

Related Questions