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.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is a method called
openFile:onNSWorkspacethat 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
opencommand.)