gpt4 book ai didi

cocoa - 在 Finder 中显示在 10.8 中不起作用

转载 作者:行者123 更新时间:2023-12-03 16:08:46 24 4
gpt4 key购买 nike

这在 10.7 中有效,但在 10.8 中无效。我如何让它在 Mountain Lion 中工作?

-(IBAction)showTargetInFinder:(id)sender
{

NSString *linkPath = [targetField stringValue];
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
[ws selectFile:linkPath inFileViewerRootedAtPath:nil];

}

最佳答案

请改用此代码:

NSURL *fileURL = your file URL;
NSArray *fileURLs = [NSArray arrayWithObjects:fileURL, nil];
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs];

这适用于 10.6+。如果您想在 Finder 上显示并选择多个文件,只需向数组中添加更多 NSURL 即可。

关于cocoa - 在 Finder 中显示在 10.8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14178244/

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