Skip to content

Commit

Permalink
Merge pull request funky-monkey#2 from BrianHenryIE/filter-syntax-update
Browse files Browse the repository at this point in the history
Swift filter() method syntax updated to new Swift 2.0 syntax
  • Loading branch information
funky-monkey committed Mar 11, 2016
2 parents 5b7e1bd + af0622c commit b6ba02d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions IsoCountryCodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
class IsoCountryCodes {

class func find( key:String ) -> IsoCountryInfo {
var country = filter( IsoCountries.allCountries, { $0.alpha2 == key.uppercaseString || $0.alpha3 == key.uppercaseString || $0.numeric == key } )
var country = IsoCountries.allCountries.filter( { $0.alpha2 == key.uppercaseString || $0.alpha3 == key.uppercaseString || $0.numeric == key } )
return country[0]
}

class func searchByName( name:String ) -> IsoCountryInfo {
var country = filter( IsoCountries.allCountries, { $0.name == name } )
var country = IsoCountries.allCountries.filter( { $0.name == name } )

return (!country.isEmpty) ? country[0] : IsoCountryInfo(name: "", numeric: "", alpha2: "", alpha3: "", calling: "", currency: "", continent: "")
}

class func searchByCurrency( currency:String ) -> [IsoCountryInfo] {
var country = filter( IsoCountries.allCountries, { $0.currency == currency } )
let country = IsoCountries.allCountries.filter( { $0.currency == currency } )
return country
}

class func searchByCallingCode( calllingCode:String ) -> IsoCountryInfo {
var country = filter( IsoCountries.allCountries, { $0.calling == calllingCode } )
var country = IsoCountries.allCountries.filter( { $0.calling == calllingCode } )
return country[0]
}
}

0 comments on commit b6ba02d

Please sign in to comment.