Created
September 28, 2020 05:54
-
-
Save olivaresf/f95d6d47647fef146263d98a5ce180b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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