It seems like this should be so simple, but I am pretty new at Objective-C. What I want to do is simply start and stop a spinner while my WebView is loading. This is an OS X app. Everything I have searched for is for Cocoa Touch, I am using just Cocoa. In my AppDelegate.m I have to methods that start and stop the spinner (This does work, I tested it).
-(IBAction)goSpin:(id)sender
{
[spinner startAnimation:self];
}
-(IBAction)stopSpin:(id)sender
{
[spinner stopAnimation:self];
}
I also have the two delegate methods for webView, which I overrode.
-(void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame
{
[self goSpin:self];
}
-(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
{
[self stopSpin:self];
}
Basically, I would like to know how I get my webView to set it’s delegate. Usually I have to do something in the .h file, but I can’t find any references that list what the webKit delegate is that would work for this. Any help would be appreciated.
The
and
methods are part of the WebFrameLoadDelegate Protocol.
WebView has a
frameLoadDelegateproperty. Set it on yourWebViewinstance by calling[webView setFrameLoadDelegate:delegate], wheredelegateis an NSObject that implements the two methods (it will be easiest for you to makeselfthe frameLoadDelegate here). Since WebFrameLoadDelegate is an informal protocol,delegateshould declare the two methods in its .h file, rather than add<WebFrameLoadDelegate>to its class declaration as with a formal protocol.