Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. override func viewDidLoad() {
  2. super.viewDidLoad()
  3. // Do any additional setup after loading the view, typically from a nib.
  4.  
  5. // Playground - noun: a place where people can play
  6.  
  7.  
  8.  
  9. let urlPath = "https://www.arqaam.co/API_OUT_PLATES.php?API_KEY=785d6cdd5b65b21cb488b043ecdd5eb885ace5f5"
  10. let url: NSURL = NSURL(string: urlPath)!
  11. let session = NSURLSession.sharedSession()
  12. let task = session.dataTaskWithURL(url, completionHandler: {data, response, error -> Void in
  13. println("Task completed")
  14. if((error) != nil) {
  15. // If there is an error in the web request, print it to the console
  16. println(error.localizedDescription)
  17. }
  18. var err: NSError?
  19. var jsonResult = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &err) as NSDictionary
  20. if(err != nil) {
  21. // If there is an error parsing JSON, print it to the console
  22. println("JSON Error (err!.localizedDescription)")
  23. } else {
  24.  
  25. println(jsonResult)
  26.  
  27. }
  28.  
  29. })
  30. task.resume()
  31.  
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement