@@ -58,30 +58,30 @@ open class MRCountryPicker: UIPickerView, UIPickerViewDelegate, UIPickerViewData
5858 // MARK: - Country Methods
5959
6060 open func setCountry( _ code: String ) {
61- var row = 0
6261 for index in 0 ..< countries. count {
6362 if countries [ index] . code == code {
64- row = index
65- break
63+ return self . setCountryByRow ( row: index)
6664 }
6765 }
68-
69- self . selectRow ( row, inComponent: 0 , animated: true )
70- let country = countries [ row]
71- if let countryPickerDelegate = countryPickerDelegate {
72- countryPickerDelegate. countryPhoneCodePicker ( self , didSelectCountryWithName: country. name!, countryCode: country. code!, phoneCode: country. phoneCode!, flag: country. flag!)
73- }
7466 }
7567
7668 open func setCountryByPhoneCode( _ phoneCode: String ) {
77- var row = 0
7869 for index in 0 ..< countries. count {
7970 if countries [ index] . phoneCode == phoneCode {
80- row = index
81- break
71+ return self . setCountryByRow ( row: index)
8272 }
8373 }
84-
74+ }
75+
76+ open func setCountryByName( _ name: String ) {
77+ for index in 0 ..< countries. count {
78+ if countries [ index] . name == name {
79+ return self . setCountryByRow ( row: index)
80+ }
81+ }
82+ }
83+
84+ func setCountryByRow( row: Int ) {
8585 self . selectRow ( row, inComponent: 0 , animated: true )
8686 let country = countries [ row]
8787 if let countryPickerDelegate = countryPickerDelegate {
0 commit comments