Is there a Mac OS X "open" command equivalent that can be called from C ++ / Objective-C code?

Mac OS X has a very useful "open" command that launches an application that matches the open file type. Is there some C ++ / Objective-C feature on Mac that does the same?

Note. I know I can run an "open" process. I'm just not sure if this is the best option.

+2


a source to share


1 answer


This is done with NSWorkspace

. See -[NSWorkspace openFile:]

. All you have to do is

[[NSWorkspace sharedWorkspace] openFile:@"file.txt"]

      



If you need more fine-grained control (for example, getting all the applications that can open a given file) you use Launch Services. See document and reference .

+4


a source







All Articles