views:

31

answers:

1

I'm about to start a new Cocoa project from scratch and one of the requirements I have already been given is being able to choose either a Cocoa GUI or a command line mode from the same executable. Scriptability may be a possible addition in the future but that is not a concern right now.

What is the best strategy for going about this in Cocoa, especially if I want to maintain certain Cocoa features like Obj-C garbage collection?

+3  A: 

Xcode will generate a main.m for you with a main function that has the command line arguments. You should parse them and if you need to stay in command-line mode, never do the application startup. If you are being a GUI, just start normally.

Lou Franco