gpt4 book ai didi

objective-c - NSWorkspace选择文件:inFileViewerRootedAtPath: does not work the first time it is called

转载 作者:行者123 更新时间:2023-12-03 17:04:43 24 4
gpt4 key购买 nike

我有一个沙盒 Cocoa 应用程序。我注意到,当我调用 [[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:path] 时,第一次调用时不会打开 Finder 窗口。 Finder.app 被带到前台(菜单栏更改为 Finder),但除此之外什么也没有发生。

当我将应用程序带回前台并再次让它在 Finder 中选择文件时,Finder 窗口将打开,并按预期选择文件。我尝试使用 @"" 作为第二个参数,同样的事情。

当 Finder 窗口已打开时,一切都会按预期运行。

还有其他人遇到过这个问题吗?解决方法是立即调用 selectFile:... 两次,但这似乎不对。

编辑:与沙箱无关。没有沙箱也有同样的问题。

最佳答案

我认为 activateFileViewerSelectingURLs 更好。它在查找器中正确选择了多个文件。

关于objective-c - NSWorkspace选择文件:inFileViewerRootedAtPath: does not work the first time it is called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13082348/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com