2012-02-13 33 views
0

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]; 

回答

0

有爲什麼NSThread不能使用的原因是什麼?這是明顯的答案...

+0

其由NSTimer定時在面板上的自定義視圖中正確顯示動畫。我想我也可以在NSThread中做到這一點,但是如果我不必這樣做,我不想再多花一分錢(並且在學習過程中學習NSThread)。 – Justin808 2012-02-13 06:51:49

相關問題