Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. [
  2. {
  3. "created_at": "Tue Mar 31 13:47:02 +0000 2015",
  4. "id": 582901921171796000,
  5. }
  6. ]
  7.  
  8. let urlPath = "http://api.twitter.com/1.1/statuses/home_timeline.json?AUTHENTICATION_INFO"
  9. let url: NSURL = NSURL(string: urlPath)!
  10. let session = NSURLSession.sharedSession()
  11. let task = session.dataTaskWithURL(url, completionHandler: {data, response, error -> Void in
  12.  
  13. if error != nil {
  14. // If there is an error in the web request, print it to the console
  15. println(error.localizedDescription)
  16. }
  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. }
  24.  
  25. let json = JSON(jsonResult)
  26.  
  27. let createdAt = json[0]["created_at"].string!
  28. println(createdAt)
  29.  
  30. })
  31. task.resume()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement