Question

I am currently trying to sandbox my app and I have been running into some strange issues with the NSOpenPanel. I am currently getting the following error when I try to display my NSOpenPanel:

Error:  Objective-C runtime exception: 
-[NSRemoteOpenPanel orderFront:]: unrecognized selector sent to instance 0x16a1630

I have read some other posts that explain that when you enable sandboxing the OS will use an NSRemoteOpenPanel instead of an NSOpenPanel and that this class may not directly inherit from an NSOpenPanel and may not implement all of its methods. Here is a stackoverflow post talking about that:

NSOpenPanel in Cocoa app with app-sandboxing gives an error

Now this all fine and good, but I wonder how is one supposed to know about which methods cannot be used with an NSOpenPanel that is sandboxed. There seems to be no public documentation about the NSRemoteOpenPanel.

Was it helpful?

Solution

You can count on basic things working around the panel's intention (getting files/directories, specifying filters, etc). Most specifically, only methods defined in NSSavePanel and NSOpenPanel are available to you. You should not code around basic window functionality as your app will not have control of the window.

From Apple's documentation:

An NSOpenPanel or NSSavePanel object inherits fewer methods with App Sandbox. If you attempt to send a message to an NSOpenPanel or NSSavePanel object, and that method is defined in the NSPanel, NSWindow, or NSResponder classes, the system raises an exception. The Xcode compiler does not issue a warning or error to alert you to this runtime behavior.

If you are directly calling openFront to display it as a panel, use NSSavePanel's beginWithCompletionHandler: instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top