简体   繁体   English

可可应用;在预览中打开文件(pdf)

[英]Cocoa app; open file (pdf) in Preview

I have a file path to a pdf and I want it to open in Preview. 我有一个pdf的文件路径,我希望它在预览中打开。 Also, I want finder to launch highlighting the file. 此外,我希望finder启动突出显示该文件。

On iOS I would do: 在iOS上我会这样做:

UIApplication app = [UIApplication sharedApplication];
[app openURL:url];

But I have no idea what's the alternative in Cocoa app. 但我不知道Cocoa应用程序中的替代品是什么。 Thanks 谢谢

You should look at NSWorkspace 你应该看看NSWorkspace

           NSString* path = [[NSString alloc] initWithBytes:installerPath.str() length:installerPath.dataLength() encoding:NSUTF16LittleEndianStringEncoding];
             [[NSWorkspace sharedWorkspace] openFile:path];
             [path release];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM