Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 443049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:07:56+00:00 2026-05-12T21:07:56+00:00

or How to simulate a home button pressed event? I need to restart my

  • 0

or “How to simulate a home button pressed event?”

I need to restart my iPhone app, and I want the program to quit, so the user will only have to start it.

If I simply use exit(0) some changes won’t get saved, as they would if the user quits by pressing the home button.

The restart needed for language change.

Related 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, language will change.

If // *** is replaced by exit(0), the language won’t change.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T21:07:56+00:00Added an answer on May 12, 2026 at 9:07 pm

    I think it’s perfectly fine to call exit, just call [[NSUserDefaults standardUserDefaults] synchronize] before you do that. You can read about the synchronize method in the Apple Documentation:

    Because this method is automatically
    invoked at periodic intervals, use
    this method only if you cannot wait
    for the automatic synchronization (for
    example, if your application is about
    to exit) or if you want to update the
    user defaults to what is on disk even
    though you have not made any changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey there, I want to simulate the press of iPhone home button and power/standby
is it possible to simulate pressing Home Button to terminate app in the automated
If I want to simulate press on home button I do this Intent startMain
I would like to simulate a call in an iPhone app. Is it possible
I dont want my app to run in background, I only want to give
I want to simulate a user clicking on an <a> themselves. After grabbing the
I need to simulate a test scenario in which I call the getBytes() method
I need to simulate multiple embedded server devices that are typically used for motor
I want to simulate many key press events. I found a solution by using
Is it possible to simulate user input in android ? For example to have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.