I am trying to use a WebView to render a page in order to create a thumbnail for a CoreData managed entity. I have a custom NSManagedObject subclass WebSiteManagedObject with a setUrl: that calls:

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

My WebSiteManagedObject is setup as the delegate, and I track the icon, title and frame load messages. I need to know when it is safe to cleanup the WebView, but I can't seem to deterministically figure out when the WebView is actually done from the delegate calls. I assumed that webView:didFinishLoadForFrame: would be the final delegate call, which it often is, but periodically, I get webView:didReceiveTitle: after the last didFinishLoadForFrame: (in all cases, it seems to be related to redirects).

Does anyone know a good way to determine when the WebView is REALLY done so I can release it? I've included the delegate implementations below. Thanks for any advice. (I realize my approach may be fundamentally flawed as well).


- (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame
{
    if(frame == [sender mainFrame]) {
        [self setValue:title forKey:@"title"];
    }
}

- (void)webView:(WebView *)sender didReceiveIcon:(NSImage *)image forFrame:(WebFrame *)frame
{
    if(frame == [sender mainFrame]) {
        [self setValue:[image TIFFRepresentation] forKey:@"favicon"];
    }
}

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

        ...

        [self setValue:[image TIFFRepresentation] forKey:@"thumbnail"];
        [sender autorelease];
    }
}


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to