• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: knowing when WebView is done
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: knowing when WebView is done


  • Subject: Re: knowing when WebView is done
  • From: Timothy Ritchey <email@hidden>
  • Date: Sat, 07 Jun 2008 01:06:44 -0400

Out of curiosity, did you ever check the retain counts on your webview objects?

I create my webview with:

- (void)setUrl:(NSString *)value
{
    [self willChangeValueForKey:@"url"];
    [self setPrimitiveUrl:value];
    [self didChangeValueForKey:@"url"];

NSRect rect = NSMakeRect(0, 0, 900, 1164);
webView = [[WebView alloc] initWithFrame:rect frameName:@"MyFrame" groupName:@"MyGroup"];
[webView setFrameLoadDelegate:self];
[webView setMainFrameURL:value];
}


and then do the following:

- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
{
if(frame == [sender mainFrame]) {


        ... grab thumbnail image ...

        [webView stopLoading:nil];
        [webView setFrameLoadDelegate:nil];
        NSLog(@"retain count (before): %d", CFGetRetainCount(webView));
        [webView release];
        NSLog(@"retain count (after): %d", CFGetRetainCount(webView));
    }
}

and the log file shows a retain count of 2 before, and 1 after. Something else is holding onto my webView, or it has been so long since I've programmed cocoa in anger that I've lost all sense of alloc/ init behavior.

Cheers,
Tim R.



On Jun 6, 2008, at 7:06 PM, Adam R. Maxwell wrote:


On Jun 5, 2008, at 7:03 PM, Timothy Ritchey wrote:
even if I track frame commit/finish load as suggested in the thread, if I try to get rid of the webview, the world falls down around me when it can't push out that last delegate call of didReceiveTitle.

I generally send stopLoading: to a webview before disposing of it (and set any delegates to nil).


I tried even counting title/icon, etc. and that didn't even help (you can see there are two calls to the title delegate, both for the main frame. There just doesn't appear to be a deterministic way to figure out when WebView is actually done, and safe to release.

Have you tried using -isLoading in the didFinishLoadForFrame: delegate method? After seeing this thread, I switched my own webview thumbnailing code to use that, since previously I was just checking to see if the main frame finished loading. Seems to work.


--
adam


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: knowing when WebView is done
      • From: "Adam R. Maxwell" <email@hidden>
References: 
 >Re: knowing when WebView is done (From: Mark Bateman <email@hidden>)
 >Re: knowing when WebView is done (From: Rush Manbert <email@hidden>)
 >Re: knowing when WebView is done (From: Timothy Ritchey <email@hidden>)
 >Re: knowing when WebView is done (From: "Adam R. Maxwell" <email@hidden>)

  • Prev by Date: Re: Garbage collector vs variable lifetime
  • Next by Date: Re: knowing when WebView is done
  • Previous by thread: Re: knowing when WebView is done
  • Next by thread: Re: knowing when WebView is done
  • Index(es):
    • Date
    • Thread