Reputation: 301
I try to switch app language from code in my iOS app. I do this
var lang = "en"
print("lang 1 = \(lang)")
print("lang 2 = \(UserDefaults.standard.array(forKey: "AppleLanguages")![0])")
UserDefaults.standard.setValue([lang], forKey: "AppleLanguages")
UserDefaults.standard.synchronize()
print("lang 3 = \(UserDefaults.standard.array(forKey: "AppleLanguages")![0])")
And the code above prints this.
lang 1 = en
lang 2 = es
lang 3 = es
Why 'lang' is not saved to UserDefaults? What I have missed?
Upvotes: 2
Views: 373
Reputation: 1929
I had a identical problem, most likely it's a case in the configuration of the run scheme
, if in application language
is non set system language
the parameter will be forced.
in this case you will not be able to overwrite
AppleLanguages
Upvotes: 1