提问人:Mike Nathas 提问时间:12/24/2017 最后编辑:alfwattMike Nathas 更新时间:3/4/2019 访问量:3258
在沙盒中使用 Cocoa NSSavePanel 导致断言失败
Using Cocoa NSSavePanel in Sandbox causes Assertion failure
问:
我正在尝试使用 NSSavePanel 并将这一行添加到我的代码中。
let test = NSSavePanel()
每次调用此代码时,都会出现此错误。 我不太确定这里发生了什么,因为我只是在创建一个新对象。 任何帮助都表示赞赏。 谢谢!
*** 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
)
答:
69赞
Jaysen Marais
1/14/2018
#1
您对该类型的权限可能仍设置为默认值File Access
User Selected File
Read Only
- 导航到目标的“功能”选项卡
- 将权限设置为
User Selected File
Read/Write
- 运行您的应用程序(错误应该消失了)
bridge absent
评论
0赞
Rick
5/15/2018
哇。为什么会这样/
0赞
ixany
6/27/2018
超级乐于助人。谢谢玛黑@Jaysen:)
0赞
promacuser
6/29/2018
@Rick 这与沙盒应用和 Mac App Store 的要求有关。您明确需要选择加入才能将内容保存在其他地方。
0赞
xBACP
8/2/2018
@Jaysen玛黑区,这刚刚救了我!
1赞
Paul Gowder
2/11/2019
顺便说一句,令人惊讶的是,这条错误消息是多么无用。你可能会认为苹果可能会包含一个描述性的错误消息,比如“权限错误”或其他什么。但不是
评论