getting data from URL in Swift
<p>I'm trying to download JSON file from server &amp; following an tutorial to do this (<a href="http://www.learnswiftonline.com/mini-tutorials/how-to-download-and-read-json/" rel="noreferrer">http://www.learnswiftonline.com/mini-tutorials/how-to-download-and-read-json/</a>)</p>

<p>First I tried 'checking the response' part (I added some part to see what's wrong)</p>

<pre><code>let requestURL: NSURL = NSURL(string: "http://www.learnswiftonline.com/Samples/subway.json")!
let urlRequest: NSMutableURLRequest = NSMutableURLRequest(URL: requestURL)
let session = NSURLSession.sharedSession()
let task = session.dataTaskWithRequest(urlRequest) {
    (data, response, error) -&gt; Void in

        let httpResponse = response as! NSHTTPURLResponse
        let statusCode = httpResponse.statusCode

        if (statusCode == 200) {
            print("Everyone is fine, file downloaded successfully.")
        } else  {
            print("Failed")
        }

task.resume()
</code></pre>

<p>This should print either "Everyone is fine~" or "Failed" but neither comes up... I tried to see statusCode so I put <code>print(statusCode)</code> inside <code>task</code> but again nothing is printed.</p>

<p>This is my screenshot of the playground:</p>

<p><a href="https://i.stack.imgur.com/jYwey.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jYwey.png" alt="enter image description here"></a></p>

<p>+</p>

<p><a href="https://stackoverflow.com/questions/25126471/cfrunloop-in-swift-command-line-program">CFRunLoop in Swift Command Line Program</a></p>

<p>This was the answer I was looking for, since I was dealing with OS X command line application (I moved the whole bunch to playground to see what would happen). Check this if you're the same with me</p>