Apparently NSURLConnection is deprecated in 10.11, so I was trying to figure out NSURLSession. For some reason code in the completionHandler is never run when building for OS X, but if I plug the same code in an iPhone project it id executed as expected.
You can either create one by hand if you want to run as a command line tool, or run that piece of code in a Cocoa application.
[/quote]
Thanks. The problem is now it never leaves the session. I tried stopping it using a while loop with a bool that changes in completion handler, and explicitly calling CFRunLoopStop(CFRunLoopGetCurrent()) in the completion handler and the loop, but it never exits.
I gave you that example on purpose, hoping that it would encourage you to start digging deeper into the architecture of a Cocoa application.
Apple provides developers with freely accessible documentation. Get into the habit of reading them seriously in addition to reading BNR books and googling things.