Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. let url=URL(string:"http://........................")
  2. let task = URLSession.shared.dataTask(with: url!) {(data, response, error) in
  3. if error != nil {
  4. print(error)
  5. }
  6. else
  7. {
  8. do
  9. {
  10. let infoJson = try JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.mutableContainers) as AnyObject
  11. if let jsonData = infoJson["data"] as? NSDictionary
  12. {
  13. self.lblAddress.text=jsonData["address"]! as? String
  14. self.lblSobstvennik.text=jsonData["consumername"]! as? String
  15.  
  16. } else {
  17.  
  18. }
  19. }
  20. catch let error {
  21. print(error.localizedDescription)
  22. }
  23. }
  24. }
  25. task.resume()
  26.  
  27. let url=URL(string:"http://........................")
  28. let task = URLSession.shared.dataTask(with: url!) {(data, response, error) in
  29. if error != nil {
  30. print(error)
  31. }
  32. else
  33. {
  34. do
  35. {
  36. let infoJson = try JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.mutableContainers) as AnyObject
  37. if let jsonData = infoJson["data"] as? NSDictionary
  38. {
  39. DispatchQueue.main.async(execute: {
  40. self.lblAddress.text=jsonData["address"]! as? String
  41. self.lblSobstvennik.text=jsonData["consumername"]! as? String
  42. })
  43.  
  44. } else {
  45.  
  46. }
  47. }
  48. catch let error {
  49. print(error.localizedDescription)
  50. }
  51. }
  52. }
  53. task.resume()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement