Guest User

Untitled

a guest
Nov 24th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. struct HYCAddress: Codable {
  2. var street: String?
  3. var zip: String?
  4. var country: String?
  5. var subThoroughfare: String?
  6. var state: String?
  7. var name: String?
  8. var subAdministratieArea: String?
  9. var thoroughfare: String?
  10. var formattedAddressLines: [String]?
  11. var city: String?
  12. var countryCode: String?
  13. var subLocality: String?
  14.  
  15. init(with addressDictionary: [String: Any]) {
  16. street = addressDictionary["Street"] as? String
  17. zip = addressDictionary["ZIP"] as? String
  18. country = addressDictionary["Country"] as? String
  19. subThoroughfare = addressDictionary["SubThoroughfare"] as? String
  20. state = addressDictionary["State"] as? String
  21. name = addressDictionary["Name"] as? String
  22. subAdministratieArea = addressDictionary["SubAdministrativeArea"] as? String
  23. thoroughfare = addressDictionary["Thoroughfare"] as? String
  24. formattedAddressLines = addressDictionary["FormattedAddressLines"] as? [String]
  25. city = addressDictionary["City"] as? String
  26. countryCode = addressDictionary["CountryCode"] as? String
  27. subLocality = addressDictionary["SubLocality"] as? String
  28. }
  29.  
  30. var dictionary: [String: Any] {
  31. var dic: [String: Any] = [:]
  32.  
  33. if let street = street {
  34. dic["Street"] = street as Any
  35. }
  36.  
  37. if let zip = zip {
  38. dic["ZIP"] = zip as Any
  39. }
  40.  
  41. if let country = country {
  42. dic["Country"] = country as Any
  43. }
  44.  
  45. if let subThoroughfare = subThoroughfare {
  46. dic["SubThoroughfare"] = subThoroughfare as Any
  47. }
  48.  
  49. if let state = state {
  50. dic["State"] = state as Any
  51. }
  52.  
  53. if let name = name {
  54. dic["Name"] = name as Any
  55. }
  56.  
  57. if let subAdministratieArea = subAdministratieArea {
  58. dic["SubAdministrativeArea"] = subAdministratieArea as Any
  59. }
  60.  
  61. if let thoroughfare = thoroughfare {
  62. dic["Thoroughfare"] = thoroughfare as Any
  63. }
  64.  
  65. if let formattedAddressLines = formattedAddressLines {
  66. dic["FormattedAddressLines"] = formattedAddressLines as Any
  67. }
  68.  
  69. if let city = city {
  70. dic["City"] = city as Any
  71. }
  72.  
  73. if let countryCode = countryCode {
  74. dic["CountryCode"] = countryCode as Any
  75. }
  76.  
  77. if let subLocality = subLocality {
  78. dic["SubLocality"] = subLocality
  79. }
  80.  
  81. return dic
  82. }
  83. }
Add Comment
Please, Sign In to add comment