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

  • Home
  • SEARCH
  • 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

I want to simulate clicking with the mouse on all elements of a given
I want to simulate a microprocessor designed using VHDL in ModelSim. I wanted to
I want to simulate this error so I can check a generic error page
I am using JBoss 5.1.0.GA on Red Hat Linux 4. We have only webservices
I am trying to simulate the Youtube Autocomplete Search experience. I can't find the
I'm trying to simulate the effect where I hover on an image an overlayed
I'm trying to simulate keyboard commands for a custom game controller application. Because I'll
How can I simulate landscape orientation in the android simulator?
How can i Simulate Left And Right Mouse Click In Asp.net Web Applications ?
I'm trying to simulate a mouse click on a window. I currently have success

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.