0

The loadFile method starts a NSTimer to load an process a file over time without blocking the application in a while loop. This timer is not firing with the first bit of code, and is with the second bit. The issue is the second bit shows the sheet as a panel style window, not as a sheet.

How do I get a sheet that can still do work?

Show Sheet but no work is done

[self.sheetView loadFile:filename];
[[NSApplication sharedApplication] beginSheet: self.sheetView
                               modalForWindow: self.window
                                modalDelegate: self
                               didEndSelector: nil
                                  contextInfo: nil];
[[NSApplication sharedApplication] runModalForWindow: self.sheetView];

Show window and work is done

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];
Justin808
  • 20,859
  • 46
  • 160
  • 265

1 Answers1

0

Is there a reason why NSThread can't be used? That's the obvious answer ...

StilesCrisis
  • 15,972
  • 4
  • 39
  • 62
  • its timed by the NSTimer to display an animation correctly in a custom view on the panel. I suppose I could do that in a NSThread as well, but I didn't want to have to go the extra mile (and learn NSThread in the process) if I didn't have to. – Justin808 Feb 13 '12 at 06:51