Okay, well I am trying to learn how to develop mac apps. I have done making a web browser and all, but I really want to know how to make the WebView load a URL (lets say http://google.com/) when the apps start. How do I do that?
In your app delegate, implement
-(void)applicationDidFinishLaunching:(NSNotification*) notification
{
....
}
This method is called automatically by the Cocoa system when the app did finish launching, quite obvious, right?
Suppose you have IBOutlet WebView*webview
in your app delegate. Then all you have to do is, inside applicationDidFinishLaunching:
, to call
NSURL*url=[NSURL URLWithString:@"http://www.google.com"];
NSURLRequest*request=[NSURLRequest requestWithURL:url];
[[webview mainFrame] loadRequest:request];
That's all!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With