在沙盒中使用Cocoa NSSavePanel会导致断言失败 [英] Using Cocoa NSSavePanel in Sandbox causes Assertion failure

查看:158
本文介绍了在沙盒中使用Cocoa NSSavePanel会导致断言失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用NSSavePanel并将此行添加到我的代码中.

I'm trying to use the NSSavePanel and added this line to my code.

let test = NSSavePanel()

每次调用此代码都会出现此错误. 我不太确定这里发生了什么,因为我只是在创建一个新对象. 任何帮助表示赞赏. 谢谢!

Everytime this code is called the this error appears. I'm not quite sure what is happening here because I'm only creating a new object. Any help appreciated. Thanks!

*** Assertion failure in -[NSVBSavePanel viewWillInvalidate:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1561.20.106/Nav.subproj/OpenAndSavePanelRemote/NSVBOpenAndSavePanels.m:387
2017-12-23 18:11:33.110099+0100 test[27753:1527254] -[NSVBSavePanel init] caught non-fatal NSInternalInconsistencyException 'bridge absent' with backtrace (
    0   CoreFoundation                      0x00007fff3ca1900b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fff635f7c76 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff3ca1eda2 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x00007fff3eb2b260 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
    4   AppKit                              0x00007fff3a1e748e -[NSVBSavePanel viewWillInvalidate:] + 188
    5   ViewBridge                          0x00007fff60f376f2 -[NSRemoteView invalidate:] + 292
    6   ViewBridge                          0x00007fff60f44e88 -[NSRemoteView _advanceToConfigPhaseLegacy] + 1111
    7   ViewBridge                          0x00007fff60f45d1b -[NSRemoteView _viewServiceMarshalProxy:withDetailedErrorHandler:] + 230
    8   ViewBridge                          0x00007fff60f46104 -[NSRemoteView _viewServiceMarshalProxy:withErrorHandler:] + 78
    9   ViewBridge                          0x00007fff60f38194 -[NSRemoteView bridge] + 227
    10  AppKit                              0x00007fff3a1a2e36 -[NSVBSavePanel init] + 292
    11  AppKit                              0x00007fff3a66fc7e -[NSSavePanel initWithContentRect:styleMask:backing:defer:] + 71
    12  AppKit                              0x00007fff3a1a3093 -[NSPanel init] + 87
    13  test                                0x0000000100002933 _T0So11NSSavePanelCABycfcTO + 19
    14  test                                0x000000010000131c _T0So11NSSavePanelCABycfC + 60
    15  test                                0x0000000100001285 _T04test14ViewControllerC11viewDidLoadyyF + 85
    16  test                                0x00000001000013b4 _T04test14ViewControllerC11viewDidLoadyyFTo + 36
    17  AppKit                              0x00007fff39fc1632 -[NSViewController _sendViewDidLoad] + 97
    18  AppKit                              0x00007fff39fb806d -[NSViewController _loadViewIfRequired] + 390
    19  AppKit                              0x00007fff39fb7e9d -[NSViewController view] + 30
    20  AppKit                              0x00007fff3a13675d -[NSWindow _contentViewControllerChanged] + 109
    21  Foundation                          0x00007fff3ea99ade -[NSObject(NSKeyValueCoding) setValue:forKey:] + 331
    22  AppKit                              0x00007fff3a1794b1 -[NSWindow setValue:forKey:] + 111
    23  AppKit                              0x00007fff3a179415 -[NSIBUserDefinedRuntimeAttributesConnector establishConnection] + 637
    24  AppKit                              0x00007fff39f45bbd -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 1430
    25  AppKit                              0x00007fff3a04113a -[NSNib _instantiateNibWithExternalNameTable:options:] + 679
    26  AppKit                              0x00007fff3a040d96 -[NSNib _instantiateWithOwner:options:topLevelObjects:] + 136
    27  AppKit                              0x00007fff3a797180 -[NSStoryboard instantiateControllerWithIdentifier:] + 236
    28  AppKit                              0x00007fff39f39ecf NSApplicationMain + 729
    29  test                                0x0000000100002d0d main + 13
    30  libdyld.dylib                       0x00007fff641e7115 start + 1
)

推荐答案

您对User Selected File类型的File Access权限可能仍设置为默认的Read Only

Your File Access permissions for the User Selected File type are probably still set to the default Read Only value

  1. 导航至目标的功能"标签

  1. User Selected File权限设置为Read/Write
  1. Set the User Selected File permission to Read/Write

  1. 运行您的应用(bridge absent错误应消失)
  1. Run your app (the bridge absent error should be gone)

这篇关于在沙盒中使用Cocoa NSSavePanel会导致断言失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆