我的Mac应用程序旨在编辑和分析图形,用户可以在文件系统的任何位置创建和存储文件.我转到用户让他们打开一个以前创建的文件[NSOpenPanel openPanel]和一个内联完成处理程序块.在菜单处理过程中,我多次收到此控制台错误消息:
2017-02-25 13:42:47.394433 pasteurnet3[32901:1263849] [default] Failed to updated bookmark for item (null) [60AF512E-6072-427D-8624-C406B0EF7D5A] - URL:file:///AirDrop with error Error Domain=NSCocoaErrorDomain Code=260 "The file couldn’t be opened because it doesn’t exist."
Run Code Online (Sandbox Code Playgroud)
只有在创建消息NSOpenPanel之前,才会发生这种情况beginWithCompletionHandler:.FWIW,菜单仍然会在最终请求时出现,允许文件选择,否则似乎工作.菜单对象的初始化似乎确实有很长的延迟.
我很长时间没有注意这个应用程序,但消息的外观显然是由于MacOS的变化.我立即怀疑沙盒,但沙盒已关闭应用程序.如果我启用沙盒并请求"用户选择的文件"权利,它似乎没有任何区别.
除了在@try块内部完成外,对象创建没有什么特别之处:
@try {
// Create the File Open Dialog class.
openDialog_ = [NSOpenPanel openPanel]; // error occurs here
}
@catch (NSException *e){
NSLog(@"innocuous exception(1) in -initForOpenWithDefaultFile:callBackTo:");
}
@catch (NSString *s){
NSLog(@"innocuous exception(2) in -initForOpenWithDefaultFile:callBackTo: \"%@\"", s);
}
@catch (...) { …Run Code Online (Sandbox Code Playgroud)