[英]Focus Finder by Mac App
我的Mac应用程序中有一个Updater,它会自动下载具有最新版本应用程序的dmg文件。 现在它也可以打开该文件,但是如何聚焦Finder窗口? 否则,用户将不知道该狗文件已打开,因为它在后台。 这是我用于下载和打开文件的代码:
NSData *fileData = [NSData dataWithContentsOfURL:
[NSURL URLWithString:@"http:// ... .dmg"]];
if([fileData writeToFile:@"/file.dmg" atomically:NO]) {
[[NSWorkspace sharedWorkspace] openFile:@"file.dmg"];
// Here I want to focus the new Finder window which has been opened by the code above
exit(1);
}
你可能会用
[[NSWorkspace sharedWorkspace] openFile:myFile withApplication:@"Finder"];
您需要使用NSWorkspace
的方法activateFileViewerSelectingURLs:
文档 )。
您将在GitHub上的showinfinder项目中找到如何使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.