Skip to content

Instantly share code, notes, and snippets.

@olivaresf
Created September 28, 2020 05:54
Show Gist options
  • Save olivaresf/f95d6d47647fef146263d98a5ce180b7 to your computer and use it in GitHub Desktop.
Save olivaresf/f95d6d47647fef146263d98a5ce180b7 to your computer and use it in GitHub Desktop.
struct Country {
var code: String?
var name: String?
var phoneCode: String?
var flag: UIImage? {
guard let code = self.code else { return nil }
return UIImage(named: "SwiftCountryPicker.bundle/Images/\(code.uppercased())", in: Bundle(for: MRCountryPicker.self), compatibleWith: nil)
}
init(code: String?, name: String?, phoneCode: String?) {
self.code = code
self.name = name
self.phoneCode = phoneCode
}
init(dictionary: NSDictionary) {
let countryNSDictionary = dictionary
code = countryNSDictionary["code"] as! String
phoneCode = countryNSDictionary["dial_code"] as! String
name = countryNSDictionary["name"] as! String
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment