Hi friends I am new to iphone. In my project am using localizations to change the language of an app. I done it but the problem. When app gets stopped and run again the language set through localization is not getting retained. So I read we need to save the languge set by localization in NSUserDefaults. Please help me. How to save it in NSUserDefaults and callback when app gets launched? Here is the code. In this way I set language
- (IBAction)EngLang:(id)sender {
[[Localization sharedInstance] setPreferred:@"en" fallback:@"es"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"en" forKey:@"Applanguage"];
}
- (IBAction)espLang:(id)sender {
[[Localization sharedInstance] setPreferred:@"es" fallback:@"en"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"es" forKey:@"Applanguage"];
}
How to save the language in NSUserDefaults and How to call it when app gets launched? Now I saved the language in NSUserDefaults. How to read it? This is the code I used to read. I done this in appDelegate.
[[NSUserDefaults standardUserDefaults] setObject: [NSArray arrayWithObjects:@"en",@"es", nil] forKey:@"Applanguage"];
[[NSUserDefaults standardUserDefaults] synchronize];