forked from funky-monkey/IsoCountryCodes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIsoCountryCodes.swift
More file actions
37 lines (29 loc) · 1.41 KB
/
IsoCountryCodes.swift
File metadata and controls
37 lines (29 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// IsoCountryCodes.swift
// IsoCountryCodes
//
// Created by Sidney de Koning on 09/01/15.
// Copyright (c) 2015 Funky Monkey, www.funky-monkey.nl. All rights reserved.
//
class IsoCountryCodes {
class func find( key:String ) -> IsoCountryInfo {
var country = IsoCountries.allCountries.filter( { $0.alpha2 == key.uppercased() || $0.alpha3 == key.uppercased() || $0.numeric == key } )
return country[0]
}
class func searchByName( name:String ) -> IsoCountryInfo {
var country = IsoCountries.allCountries.filter( { $0.name == name } )
return (!country.isEmpty) ? country[0] : IsoCountryInfo(name: "", numeric: "", alpha2: "", alpha3: "", calling: "", currency: "", continent: "")
}
class func searchByNumeric( numeric:String ) -> IsoCountryInfo {
let country = IsoCountries.allCountries.filter( { $0.numeric == numeric } )
return (!country.isEmpty) ? country[0] : IsoCountryInfo(name: "", numeric: "", alpha2: "", alpha3: "", calling: "", currency: "", continent: "")
}
class func searchByCurrency( currency:String ) -> [IsoCountryInfo] {
let country = IsoCountries.allCountries.filter( { $0.currency == currency } )
return country
}
class func searchByCallingCode( calllingCode:String ) -> IsoCountryInfo {
var country = IsoCountries.allCountries.filter( { $0.calling == calllingCode } )
return country[0]
}
}