Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting a default program in OSX programmatically

How do I start XCode (or any other default program associated with a file) and make it open a specific file programmatically? Similar to double-clicking a .c in Finder - it opens an XCode editor with the file.

like image 251
AWF4vk Avatar asked Oct 10 '22 10:10

AWF4vk


1 Answers

There is a method called openFile: on NSWorkspace that does exactly this.

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSWorkspace_Class/Reference/Reference.html

(For bonus points, if you want to do it from the shell, you can use the open command.)

like image 152
Jeremy Roman Avatar answered Oct 31 '22 03:10

Jeremy Roman