I created custom NSPanel and I show it bengin with Sheet. On it do not have any button to close, I want to close this panel with NSTimer after 10s. How can I do that?
[[NSApplication sharedApplication] beginSheet: scanningPanel
modalForWindow: window
modalDelegate: self
didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo: nil];
[[NSApplication sharedApplication] runModalForWindow: scanningPanel];
NSTimer *myTimer = [NSTimer timerWithTimeInterval: 10.0
target:self
selector: @selector(closePanel:) userInfo:nil
repeats:NO];
[[NSRunLoop currentRunLoop] addTimer:myTimer forMode:NSModalPanelRunLoopMode];
closePanel () function :
-(void) closePanel: (NSTimer *) theTimer
{
NSLog(@"closePanel");
[scanningPanel abortModal]; // seems it not work
}
Try this: