On Aug 11, 2007, at 9:31 AM, Paul FitzGerald wrote:
I'm wondering about the correct way to build a WebView on-the-fly
and how to destroy it when I'm done. I'm currently getting random
crashes (only thing in the stack crawl is "longjump" or something
like that).
Anyway, This is what I'm doing to create/destroy my WebView. There
is not much in the documentation about how to do this.
Create...
NSRect myRect = [[myWindow contentView] frame];
myWebKitView = [[WebView alloc] initWithFrame:myRect
frameName:nil groupName:nil];
[[myWindow contentView] addSubview:myWebKitView];
[myWindow setLevel:NSFloatingWindowLevel];
[myWindow makeKeyAndOrderFront:nil];
Destroy...
[myWebKitView removeFromSuperview];
myWebKitView = nil;
[myWindow orderOut:self]; // Hide Window.
Unless you're using garbage collection, you need to release the
view because you've alloc'd it:
[myWebKitView removeFromSuperview];
[myWebKitView release];