Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do any additional setup after loading the view, typically from a nib.
- // Playground - noun: a place where people can play
- let urlPath = "https://www.arqaam.co/API_OUT_PLATES.php?API_KEY=785d6cdd5b65b21cb488b043ecdd5eb885ace5f5"
- let url: NSURL = NSURL(string: urlPath)!
- let session = NSURLSession.sharedSession()
- let task = session.dataTaskWithURL(url, completionHandler: {data, response, error -> Void in
- println("Task completed")
- if((error) != nil) {
- // If there is an error in the web request, print it to the console
- println(error.localizedDescription)
- }
- var err: NSError?
- var jsonResult = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &err) as NSDictionary
- if(err != nil) {
- // If there is an error parsing JSON, print it to the console
- println("JSON Error (err!.localizedDescription)")
- } else {
- println(jsonResult)
- }
- })
- task.resume()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement