I am running a custom NSWindowController as modal window.
First I show it like this:
ProgressWindow *pWin = [[ProgressWindow alloc] initWithWindowNibName:@"ProgressWindow" andXmlContent:nil];
[NSApp runModalForWindow:[pWin window]];
And then I want to dismiss it from within the ProgressWindow's NSWindowController. To do so I set at the windowDidLoad function following code (just to test):
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2]];
[self testMethod];
As expected, it calls testMethod after 2 Seconds The method should close the modal window, but I don't seem to find the way to do it. I have tried [NSApp stopModal]
, [NSApp abortModal]
, [self close]
, making it a sheet and calling [self.window orderOut:nil];[NSApp endSheet:self.window];
but nothing seems to work. Either nothing happens or the window reopens at another location. I do not know why this is happening, the initialization code is only called once.
Anyone knows how to close it???