(After comment response:)
Something for you to try (I can't test your scenario). NSOpenPanel
/NSSavePanel
are very delicate classes since the introduction of sandbox and need to be handled with care.
All UI operations need to be performed on the main thread, as you have discovered. However instead of using the dispatch_*
functions try using a synchronous performSelectorOnMainThread
:
NSOpenPanel * dlg = [NSOpenPanel openPanel];
... //setting title and other properties for dlg
resButton = [dlg performSelectorOnMainThread:@selector(runModal)
withObject:nil
waitUntilDone:YES];
if (resButton == NSFileHandlingPanelOKButton) //resButton is global
{...}
That may solve your issue, or not...
Addendum
My bad, as you correctly point out performSelectorOnMainThread
doesn't return a value. You can instead:
Add resButton
as an instance variable to your class.
Add the method:
- (void) myRunModal:(NSOpenPanel *)dlg
{
resButton = [dlg runModal];
}
Change the code to:
[self performSelectorOnMainThread:@selector(myRunModal:)
withObject:dlg
waitUntilDone:YES];
Or something similar.