简体   繁体   English

使用app-sandboxing的Cocoa app中的NSOpenPanel会出错

[英]NSOpenPanel in Cocoa app with app-sandboxing gives an error

I am doing a simple file open panel in my Cocoa app. 我正在Cocoa应用程序中做一个简单的文件打开面板。 I enable entitlements and app sandboxing and the following code now gives me an error on setFloatingPanel. 我启用了权利和应用程序沙盒,以下代码现在在setFloatingPanel上给出了一个错误。 Can't figure out why? 想不通为什么?

NSArray* fileTypes = [[NSArray alloc] initWithObjects:@"png", @"PNG", nil];  
NSOpenPanel *panel;
panel = [NSOpenPanel openPanel];
[panel setTitle:@"Select Photo"];
[panel setFloatingPanel:YES];

result in the following error 导致以下错误

2012-02-14 11:43:45.831 MyApp[451:707] -[NSRemoteOpenPanel setFloatingPanel:]: unrecognized selector sent to instance 0x400886ea0
2012-02-14 11:43:45.832 MyApp[451:707] -[NSRemoteOpenPanel setFloatingPanel:]: unrecognized selector sent to instance 0x400886ea0
2012-02-14 11:43:45.837 MyApp[451:707] (
    0   CoreFoundation                      0x00007fff83b18286 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff8b7f0d5e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff83ba44ce -[NSObject doesNotRecognizeSelector:] + 190
    3   CoreFoundation                      0x00007fff83b05133 ___forwarding___ + 371
    4   CoreFoundation                      0x00007fff83b04f48 _CF_forwarding_prep_0 + 232
    5   MyApp                               0x0000000100019f77 openFiles + 519
    6   MyApp                               0x0000000100012b19 -[MyController addImageButtonClicked:] + 25
    7   CoreFoundation                      0x00007fff83b07a1d -[NSObject performSelector:withObject:] + 61
    8   AppKit                              0x00007fff878d9710 -[NSApplication sendAction:to:from:] + 139
    9   AppKit                              0x00007fff878d9642 -[NSControl sendAction:to:] + 88
    10  AppKit                              0x00007fff878d956d -[NSCell _sendActionFrom:] + 137
    11  AppKit                              0x00007fff878d8a30 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2014
    12  AppKit                              0x00007fff879588e0 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 489
    13  AppKit                              0x00007fff878d763a -[NSControl mouseDown:] + 786
    14  AppKit                              0x00007fff878a20e0 -[NSWindow sendEvent:] + 6306
    15  AppKit                              0x00007fff8783a68f -[NSApplication sendEvent:] + 5593
    16  AppKit                              0x00007fff877d0682 -[NSApplication run] + 555
    17  AppKit                              0x00007fff87a4f80c NSApplicationMain + 867
    18  MyApp                               0x0000000100001f4c main + 44
    19  MyApp                               0x0000000100001f14 start + 52
    20  ???                                 0x0000000000000003 0x0 + 3
)

As you've mentioned you've enabled app sandboxing, that explains why you're seeing NSRemoteOpenPanel in your crash log. 正如您所提到的,您已经启用了应用程序沙盒,这就解释了为什么您在崩溃日志中看到了NSRemoteOpenPanel

Apparently Apple's NSRemoteOpenPanel doesn't descend from NSOpenPanel or NSSavePanel or NSPanel (which is where the setFloatingPanel method gets defined). 显然,Apple的NSRemoteOpenPanel并非源自NSOpenPanelNSSavePanelNSPanel (在setFloatingPanel方法的定义位置)。

I'd recommend filing an enhancement request (or bug) at http://bugreporter.apple.com 我建议在http://bugreporter.apple.com上提交增强请求(或错误)

It also may be that Apple doesn't want sandboxed apps to have floating panels or windows that live outside the "normal" Window layer, in which case your bug will get closed or commented upon really quick. 它也可能是Apple不希望沙盒应用程序具有浮动面板或窗口,这些窗口或窗口位于“正常”窗口层之外,在这种情况下,您的错误将很快关闭或评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM