• 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: Using NSURLSession in a command line tool?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using NSURLSession in a command line tool?


  • Subject: Re: Using NSURLSession in a command line tool?
  • From: Roland King <email@hidden>
  • Date: Mon, 16 Mar 2015 16:20:57 +0800

> On 16 Mar 2015, at 16:10, Daryle Walker <email@hidden> wrote:
>
> How should something like a NSURLSession be used in a command-line tool? Its actions take time, so a straight CLI program will end when the task is being started. I guess something like a run loop needs to be maintained. I need the results of the task to determine the return code, so I can’t just fire and forget.
>

Yep - run a runloop. That’s what I do in one of my command-line tools which uses USB and has to wait around for discovery and background threads and NSTasks and all sorts of amusing things.

main() has, very near the end,

	CFRunLoopRun();

and when I’ve done all the processing I need to do, or have an error, I call

	CFRunLoopStop( [ [ NSRunLoop mainRunLoop ] getCFRunLoop ];

and the main runloop then eventually exits and I clean up.

I believe I used the CFRunLoop* functions because I don’t recall the NSRunLoop ones giving you a nice simple stop method.




_______________________________________________

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


  • Follow-Ups:
    • Re: Using NSURLSession in a command line tool?
      • From: Charles Srstka <email@hidden>
References: 
 >Using NSURLSession in a command line tool? (From: Daryle Walker <email@hidden>)

  • Prev by Date: Using NSURLSession in a command line tool?
  • Next by Date: Re: Using NSURLSession in a command line tool?
  • Previous by thread: Using NSURLSession in a command line tool?
  • Next by thread: Re: Using NSURLSession in a command line tool?
  • Index(es):
    • Date
    • Thread