title: Swift: Async callback in command line utility
body: <p>I'm trying to fetch data from a website via a command line utility in swift. I'm using <code>NSURLConnection</code> for this. Like so:</p>
  
  <pre><code>private let queue = NSOperationQueue.mainQueue()
  
  NSURLConnection.sendAsynchronousRequest(NSURLRequest(URL: url), queue: queue) { (response: NSURLResponse!, data: NSData!, error: NSError!) -&gt; Void in
          println("Hello")
  }
  </code></pre>
  
  <p>But the application stops running before the callback is called. How do I keep the application running so it won't exit early? I found <code>CFRunLoop()</code> and have added that in my main file. Now the application doesn't terminate. But I still don't get a response.</p>
  
  <p>The same project in a playground with <code>XCPSetExecutionShouldContinueIndefinitely</code> does work however. So the problem does not lie in the NSURLConnection code.</p>