0xSina
0xSina

Reputation: 21553

Cocoa app; open file (pdf) in Preview

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.

On iOS I would do:

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

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

Upvotes: 3

Views: 2654

Answers (1)

Aditya Kumar Pandey
Aditya Kumar Pandey

Reputation: 991

You should look at NSWorkspace

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

Upvotes: 7

Related Questions