mac os x invoke calling another application from a

2019-09-09 15:33发布

问题:

I need to call another application inside my application (Mac OS X app). For example if I have PDF in my bundle and I want to see it call load the PDF in the viewer app. How can call the viewer and load the PDF on bundle?, any of you knows how can I do this?, I'll really appreciate your help.

回答1:

NSWorkspace does this kind of stuff the documentation has near the top the example code

[[NSWorkspace sharedWorkspace] openFile:@"/Myfiles/README"
                        withApplication:@"TextEdit"];


回答2:

You can invoke, openURL to open the default PDF viewer

[NSWorkspace sharedWorkspace] openFile: pdfFilePath];

and if you want to launch the application you can invoke

[[NSWorkspace sharedWorkspace] launchApplication:appPath];

Want to open PDF within your application then I recommend you to read PDFKit: Apple PDFKit Doc



标签: ios xcode macos