Guest User

Untitled

a guest
Jan 16th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. {
  2. "result": [
  3. {
  4. "values": [
  5. {
  6. "value":"null",
  7. "key":"symbol_2"
  8.  
  9. },
  10. {
  11. "value":"null",
  12. "key":"symbol_1"},
  13. {
  14. "value":"016",
  15. "key":"company"
  16.  
  17. },
  18. {
  19. "value":"QUW12DO",
  20. "key":"direction"
  21.  
  22. },
  23. {
  24. "value":"TD-4WYS",
  25. "key":"road"
  26.  
  27. },
  28. {
  29. "value":"04:35:00",
  30. "key":"time"
  31.  
  32. }]},
  33.  
  34. URLSession.shared.dataTask(with: (url as URL?)!, completionHandler: {(data, response, error) -> Void in
  35.  
  36.  
  37.  
  38. if let jsonObj = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? NSDictionary {
  39.  
  40. print(jsonObj!.value(forKey: "result")!)
  41.  
  42. if let stopsArray = jsonObj!.value(forKey: "result") as? NSArray {
  43.  
  44. for stop in stopsArray{
  45.  
  46.  
  47. if let stopDict = stop as? NSDictionary {
  48.  
  49.  
  50. let hours = stopDict.value(forKey: "time")
  51.  
  52. let myModel = Hours(hours: hours as? String)
  53. self.list.append(myModel)
  54. print("LIST: (self.list)")
  55.  
  56. DispatchQueue.main.async {
  57. self.actInd.stopAnimating()
  58. self.actInd.isHidden = true
  59. self.containerLittle.isHidden = true
  60. self.loadingView.isHidden = true
  61. }
  62. }
  63. }
  64.  
  65. }
  66. }
  67. }).resume()
Add Comment
Please, Sign In to add comment