• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: how to make cocoa application run as a command line tool?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to make cocoa application run as a command line tool?


  • Subject: Re: how to make cocoa application run as a command line tool?
  • From: Jeremy Pereira <email@hidden>
  • Date: Tue, 20 Oct 2009 12:27:02 +0100


On 20 Oct 2009, at 12:20, Jeremy Pereira wrote:



When I need to do this, I create a switch which puts the app into "command line" mode.

static int commandLine(int argc, const char* argv[]);

int main(int argc, char *argv[])
{
     if (argc > 1)
     {
             if (strcmp(argv[1], "-commandLine") == 0)
             {
                     return commandLine(argc, argv);
             }
     }
     else
     {
             return NSApplicationMain(argc,  (const char **) argv);
     }
}

Got that wrong. I think

     if (argc > 1 && strcmp(argv[1], "-commandLine") == 0)
     {
     		return commandLine(argc, argv);
     }
     else
     {
             return NSApplicationMain(argc,  (const char **) argv);
     }

might be better.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >how to make cocoa application run as a command line tool? (From: XiaoGang Li <email@hidden>)
 >Re: how to make cocoa application run as a command line tool? (From: Paul M <email@hidden>)
 >Re: how to make cocoa application run as a command line tool? (From: Jeremy Pereira <email@hidden>)

  • Prev by Date: Re: how to make cocoa application run as a command line tool?
  • Next by Date: Re: Dirty rects getting merged together makes for inefficient drawing
  • Previous by thread: Re: how to make cocoa application run as a command line tool?
  • Next by thread: iPhone: UIDatePicker plus touch events?
  • Index(es):
    • Date
    • Thread