可可应用;在预览中打开文件(pdf) [英] Cocoa app; open file (pdf) in Preview

查看:89
本文介绍了可可应用;在预览中打开文件(pdf)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个pdf的文件路径,我希望它在预览中打开。此外,我想finder启动突出显示文件。

I have a file path to a pdf and I want it to open in Preview. Also, I want finder to launch highlighting the file.

在iOS上我会:

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

但我不知道Cocoa应用程序的替代方法。
感谢

But I have no idea what's the alternative in Cocoa app. Thanks

推荐答案

您应该看看NSWorkspace

You should look at NSWorkspace

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

这篇关于可可应用;在预览中打开文件(pdf)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆