If I override/alter the AppleLanguages in NSUserDefaults, iOS does not update the list anymore when the system language is changed. If I leave the list unchanged, the first object in the array will always be the system language, however, if I insert a new object at index 0 and later on change the system language, iOS will not put the new language on the top of the list anymore. Is there a way to alter AppleLanguages in NSUserDefaults and still have the system update the list when the system language changes?
The solution from Accatyyc works excellent, here is the solution if you are using Swift:
Create a main.swift file, add the Swift version of the code in the accepted answer:
NSUserDefaults.standardUserDefaults().removeObjectForKey("AppleLanguages")
UIApplicationMain(Process.argc, Process.unsafeArgv, NSStringFromClass(UIApplication), NSStringFromClass(AppDelegate))
Go to the AppDelegate and remove the following line:
@UIApplicationMain //Removing this tells Xcode to use your main.swift file
I found a solution after some trial and error! Removing the whole AppleLanguages key seems to restore it to what the user has set in the settings application:
int main(int argc, char *argv[])
{
@autoreleasepool {
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"AppleLanguages"];
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With