As you can see in the screen below, iOS Calendar app shows the list of available time zone in City, Country
format.
I want to attain the same list. Where can I get this list?
As you can see in the screen below, iOS Calendar app shows the list of available time zone in City, Country
format.
I want to attain the same list. Where can I get this list?
You cannot get a "City, County" format, but you can get a "City, Continent" format using this piece of code:
let timeZones = TimeZone.knownTimeZoneIdentifiers.flatMap{ id->String? in
let components = id.components(separatedBy: "/")
guard components.count == 2, let continent = components.first, let city = components.last else {return nil}
return "\(city), \(continent)"
}
Output will be:
"Abidjan, Africa", "Accra, Africa", "Addis_Ababa, Africa", "Algiers, Africa", "Asmara, Africa", "Bamako, Africa", "Bangui, Africa", "Banjul, Africa"...
TimeZone
has a static function knownTimeZoneIdentifiers
which returns an array of String identifiers. Documentation