Answers ( 1 )

  1. 2017-01-07 13:01

    I think the best option for me here is to generate the code myself. To help with this I have created an extension on Locale:

    extension Locale {
        var iso3166code: String {
            guard
                let language = languageCode,
                let region = regionCode
                else { return "en-US" }
            return "\(language)-\(region)"
        }
    }
    

    While this is accurate enough for my purposes, you should probably ensure it returns expected values for your project.

◀ Go back