I have the following code in a window controller as part of a single web browser
+ (id)sharedPurchaseController { static SomeController *sharedController = nil; if (!sharedController) { sharedController = [[SomeController alloc] initWithWindowNibName:@"anXIB"]; } return sharedController; } - (void)awakeFromNib{ shouldReloadWeb = NO; [progressIndicator startAnimation:nil]; NSString* urlText = [NSString stringWithString:@"http://www.google.com"]; [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlText]]]; } -(void)windowWillClose:(NSNotification *)notification{ shouldReloadWeb = YES; } - (void)windowDidBecomeKey:(NSNotification *)notification{ if (shouldReloadWeb){ WebFrame* aFrame = [webView mainFrame];
The problem is that when the NSWindow (browser) closes and then opens again, [webView mainFrame] returns nil. NSWindow appears on the screen, but the WebView does not respond.
If I comment on the code that creates the singleton, everything works as expected.
Is it possible to create a singleton browser with an application while storing a WebView in Nib?
Thanks, -Ben
source share