When I use Sandboxing in a Mac app, I click a menu item "export", it should open a dialog using NSOpenPanel, but it does not. Here's the code I have:

[playExportPanel beginSheetModalForWindow:mainWindow
                        completionHandler: ^(NSInteger result) {
     if(result == NSFileHandlingPanelOKButton) {
             ....
     }
}]

It throws an exception: -[NSRemoteOpenPanel close]: unrecognized selector sent to instance. What is NSRemoteOpenPanel? Has anyone seen this before?

有帮助吗?

解决方案

I just fixed this issue in my own app. I removed the [sheet close];. Then I replaced it with [sheet orderOut:self]; later. The latter may not be necessary in your case. In my code an error sheet may be displayed from the block code before it returns. This would cause stacked sheets, which I don’t like having in this constellation: it looks cluttered.

You probably migrated to “-beginSheetModalForWindow:completionHandler:” form the deprecated API and reused your older code. Even though the call to -close is removed the panel is closed after the block returns. This is probably part of the behavior of the new API, but I have yet to find that described in the documentation.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top