objective-c - [NSOpenPanel openPanel] 调用上的 "Failed to updated [sic] bookmark for item"

标签 objective-c macos sandbox bookmarks nsopenpanel

My Mac 应用程序旨在编辑和分析图形,用户可以在文件系统的任何位置创建和存储这些图形。我去找用户让他们用 [NSOpenPanel openPanel] 和一个内联完成处理程序 block 打开一个以前创建的文件。在菜单处理期间,我多次收到此控制台错误消息:

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."

这发生在 NSOpenPanel 的创建过程中,甚至在向它发送 beginWithCompletionHandler: 消息之前。 FWIW,菜单仍然会在最终请求时出现,允许选择文件,否则似乎可以工作。菜单对象的初始化似乎确实有很长的延迟。

我已经很长时间没有关注这个应用程序了,但消息的出现显然是由于 MacOS 的变化。我立即怀疑沙盒,但该应用程序的沙盒已关闭。如果我打开沙盒并请求“用户选择的文件”授权,它似乎没有任何区别。

除了在 @try block 中完成之外,对象创建没有什么特别之处:

@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 (...) {
    NSLog(@"innocuous exception(3) in -initForOpenWithDefaultFile:callBackTo: probably a layout error");
}
@finally {
    ;
}

我没有在程序中对书签做任何事情,也没有对 AirDrop 做任何事情。

Xcode 8.2.1,Macbook MacOS 10.12.3。

最佳答案

对我来说,当我的应用程序的"file">“打开最近”菜单包含我打开的文件的项目时,“无法更新项目的书签(空)”被记录下来,然后在 Finder 中删除。我不知道是否有办法让菜单只删除项目,但我通过在运行我的应用程序时选择"file">“打开最近”>“清除菜单”来删除消息。

我的应用不使用 NSDocument。我正在使用 -noteNewRecentDocumentURL 添加项目以打开最近。

关于objective-c - [NSOpenPanel openPanel] 调用上的 "Failed to updated [sic] bookmark for item",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42459384/

相关文章:

objective-c - Objective-C 中的 id 指针

iphone - 保存用户默认值时出现随机 BAD ACCESS

macos - Mac沙盒: testing whether a file is accessible

java - 同一 JavaVM 中的多个沙箱

objective-c - 警告 : passing argument 1 of 'CGPathMoveToPoint' discards qualifiers from pointer target type

ios - 在 Objective C 中,有没有更简洁的方法来测试动态创建的 NSSet 的成员资格?

linux - 按月查找似乎缺少文件

git - 加载我的私钥以用于 Mac 上的 git

objective-c - 在MetalKit应用程序中处理输入事件

objective-c - 写入文档的封闭文件夹