Using NSURLSession from a Swift command line program
You can use a semaphore to block the current thread and wait for your URL session to finish. Create the semaphore, kick off your URL session, then wait on the semaphore. From your URL session completion callback, signal the semaphore. You could use a global flag (declare a volatile boolean variable) and poll that from … Read more