Reputation: 18542
On Mac OS X there is a very useful "open" command which launches an application suitable for opened file type. Is there some C++/Objective-C function on Mac which does the same?
Note: I know I could launch an "open" process. I'm just not sure if it's the best option.
Upvotes: 3
Views: 264
Reputation: 34185
That is done by NSWorkspace
. See -[NSWorkspace openFile:]
. All you have to do is
[[NSWorkspace sharedWorkspace] openFile:@"file.txt"]
If you want more fine-grained control (e.g. getting all applications which can open a given file,) you use Launch Services. See the document and the reference.
Upvotes: 4