Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. var url : String = "http://demo.revivalx.com/todolist-api/get_all_tasks.php"
  2. var request : NSMutableURLRequest = NSMutableURLRequest()
  3. request.URL = NSURL(string: url)
  4. request.HTTPMethod = "GET"
  5.  
  6. NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue(), completionHandler:{ (response:NSURLResponse!, data: NSData!, error: NSError!) -> Void in
  7. var error: AutoreleasingUnsafeMutablePointer<NSError?> = nil
  8. let jsonResult: NSDictionary! = NSJSONSerialization.JSONObjectWithData(data, options:NSJSONReadingOptions.MutableContainers, error: error) as? NSDictionary
  9.  
  10. if (jsonResult != nil) {
  11. //handling JSON data here
  12. } else {
  13. // couldn't load JSON, look at error
  14. }
  15.  
  16. })
  17.  
  18. {
  19. "tasks": [{
  20. "taskId": "27",
  21. "name": "testy",
  22. "description": "ggg",
  23. "dateCreated": "2014-12-03 17:01:00",
  24. "dateUpdated": "2014-12-03 17:01:00"
  25. }, {
  26. "taskId": "28",
  27. "name": "asd",
  28. "description": "asda",
  29. "dateCreated": "2014-12-04 12:21:54",
  30. "dateUpdated": "2014-12-09 10:39:26"
  31. }, {
  32. "taskId": "29",
  33. "name": "asd",
  34. "description": "asd",
  35. "dateCreated": "2014-12-04 12:21:58",
  36. "dateUpdated": "2014-12-09 10:39:47"
  37. }],
  38. "success": 1
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement