or "How to simulate a button press on a home button?"
I need to restart the application for the iPhone, and I want the program to exit, so the user only needs to start it.
If I just use exit(0), some changes will not be saved, as if the user left by pressing the home button.
Restart required to change the language.
Associated Code:
- (void)onChangeLanguage: (id)sender {
NSArray *lang = [NSArray arrayWithObjects:((Whatever *)sender).newLanguage, nil];
[[NSUserDefaults standardUserDefaults] setObject:lang forKey:@"AppleLanguages"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];
NSLog(@"Current language: %@", currentLanguage);
}
If the user restarts using the home button, the language will change.
If // ***replaced by exit(0), the language will not change.
source
share