本文介绍了沙箱应用程式& NSOpenPanel导致崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我在我的Cocoa应用程序中做一个简单的文件打开面板。我启用权利和应用程式沙箱。 但是在OS X 10.9,当应用程序使用 NSOpenPanel 打开一个对话框时,会崩溃: 应用程序特定信息: 由于未捕获异常NSObjectNotAvailableException而终止应用程序,原因:service com.apple.appkit.xpc.openAndSavePanelService无法初始化NSOpenPanelService的实例代表{proxy-communications-error=错误域= NSCocoaErrorDomain代码= 4099 \\U041d\U0435 \U0443\U0434\U0430\U043b\U043e \U0441\U044c \U0443\U0441\U0442\U0430\U043d\U043e\U0432\U0438\U0442\U044c \U0441\U0432\U044f\U0437\ U044c \U0441 \U043f\U0440\U043e\U0433\U0440\U0430\U043c\U043c\U043e\U0439 -\U043f\U043e\U043c\U043e\U0449 \U043d\U0438\U043a\U043e\U043c.\(连接从此进程失效。)UserInfo = 0x61000047dc00 {NSDebugDescription =连接从此进程无效。 }' 资料来源: code> self.panel = [NSOpenPanel openPanel]; panel.delegate = self; panel.canChooseDirectories = YES; panel.canChooseFiles = NO; panel.canCreateDirectories = YES; panel.allowsMultipleSelection = NO; [self.panel beginSheetModalForWindow:contextWindow completionHandler:^(NSInteger returnCode){ ... }];有没有人看过这个? >解决方案确实,您必须专门允许对用户选择的文件的读/写权限。在Xcode 5.1中,它位于Capabilities - App Sandbox下。 I am doing a simple file open panel in my Cocoa app. I enable entitlements and app sandboxing.But on OS X 10.9, when the app should open a dialog using NSOpenPanel, it crashes with: Application Specific Information: Terminating app due to uncaught exception 'NSObjectNotAvailableException', reason: 'service com.apple.appkit.xpc.openAndSavePanelService failed to init an instance of NSOpenPanelService on behalf of due to { "proxy-communications-error" = "Error Domain=NSCocoaErrorDomain Code=4099 \"\U041d\U0435 \U0443\U0434\U0430\U043b\U043e\U0441\U044c \U0443\U0441\U0442\U0430\U043d\U043e\U0432\U0438\U0442\U044c \U0441\U0432\U044f\U0437\U044c \U0441 \U043f\U0440\U043e\U0433\U0440\U0430\U043c\U043c\U043e\U0439-\U043f\U043e\U043c\U043e\U0449\U043d\U0438\U043a\U043e\U043c.\" (The connection was invalidated from this process.) UserInfo=0x61000047dc00 {NSDebugDescription=The connection was invalidated from this process.}"; }'Source:self.panel = [NSOpenPanel openPanel];panel.delegate = self;panel.canChooseDirectories = YES;panel.canChooseFiles = NO;panel.canCreateDirectories = YES;panel.allowsMultipleSelection = NO;[self.panel beginSheetModalForWindow:contextWindow completionHandler:^(NSInteger returnCode) { ... }];Has anyone seen this before? 解决方案 Indeed, you have to specifically allow Read/Write permissions on User Selected Files. In Xcode 5.1 this is under Capabilities - App Sandbox. 这篇关于沙箱应用程式& NSOpenPanel导致崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-12 20:27