views:

59

answers:

1

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.

+3  A: 

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.

Yuji