Skip to content

Instantly share code, notes, and snippets.

@Jan0707
Created April 16, 2015 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jan0707/cc8db99778c0f527bef5 to your computer and use it in GitHub Desktop.
Save Jan0707/cc8db99778c0f527bef5 to your computer and use it in GitHub Desktop.
SwiftyJSONDebug.swift
//: Playground - noun: a place where people can play
import UIKit
import XCPlayground
XCPSetExecutionShouldContinueIndefinitely()
let url = NSURL(string: "http://api.tvmaze.com/shows/1?embed=previousepisode")!
let session = NSURLSession.sharedSession()
session.dataTaskWithURL(url, completionHandler: {(data, response, error) in
let json = JSON(data: data)
println("Fetching")
if let previousEpisodeUrl = json["_links"]["previousepisode"]["href"].URL {
println("Result:")
println(previousEpisodeUrl)
} else {
println("Error:")
println(json["_links"]["previousepisode"]["href"].error)
}
}).resume()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment