该loadFile
方法NSTimer
随着时间的推移开始加载一个文件,而不会在while循环中阻塞应用程序。这个定时器不是用代码的第一位触发的,而是用第二位触发的。问题是第二位将工作表显示为面板样式窗口,而不是工作表。
如何获得仍然可以工作的工作表?
显示工作表但未完成任何工作
[self.sheetView loadFile:filename];
[[NSApplication sharedApplication] beginSheet: self.sheetView
modalForWindow: self.window
modalDelegate: self
didEndSelector: nil
contextInfo: nil];
[[NSApplication sharedApplication] runModalForWindow: self.sheetView];
显示窗口和工作完成
NSModalSession session = [NSApp beginModalSessionForWindow:self.sheetView];
NSInteger result = NSRunContinuesResponse;
[self.sheetView loadFile:filename];
// Loop until some result other than continues:
while (result == NSRunContinuesResponse)
{
// Run the window modally until there are no events to process:
result = [NSApp runModalSession:session];
// Give the main loop some time:
[[NSRunLoop currentRunLoop] limitDateForMode:NSDefaultRunLoopMode];
}
[NSApp endModalSession:session];