I want to detect which language the user have for the device. Then I want to change the language to a different language the app will load appropriate images, strings, storyboards.
I used the following to detect the language:
let lang: String = NSLocale.preferredLanguages()[0] as String
However this will return "en" for me even my iOS simulator is set to Arabic language.
Based on Objective-C questions, I tried to do the following to change the language to Arabic:
NSUserDefaults.setValue("ar", forKey: "AppleLanguage")
But this issues an error:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSUserDefaults 0x103daa350> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key AppleLanguage.'