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 5994853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:52:36+00:00 2026-05-22T23:52:36+00:00

I am trying to store information in NSUserdefault. My intention is to show a

  • 0

I am trying to store information in NSUserdefault. My intention is to show a pop up message to the user if it is the first time he/she is launching the app. My code is as follows:

//In my view did load method
self.prefs = [NSUserDefaults standardUserDefaults];
self.firstTimeLaunchingApp = [prefs integerForKey:@"firstTimeLaunchx"];
[self tableRefresh];

//This method is called after the refresh button is clicked
-(void)tableRefresh
{
    [self displayFirstTimeMessage];

    //Other codes ommited
}


//Method to display pop up if first time user
-(void) displayFirstTimeMessage
{
    if (self.firstTimeLaunchingApp != 1 ) 
    {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Welcome!" 
                                                   message:@"Thanks for using the app!"
                                                  delegate:nil
                                         cancelButtonTitle:@"OK"
                                         otherButtonTitles:nil];

        [alert show];
        [alert release];

        [prefs setInteger:1 forKey:@"firstTimeLaunchx"]; 
        [prefs synchronize];
    }

}

The issue I am facing here is that when I first launch the app, the alert popup appears (which is as expected), however when I click on the refresh button (which will trigger the “displayFirstTimeMessage” again), I still see the alert popup which is not as expected. Is there something wrong with the way I am setting the key for NSUserDefault?

Note: If I stop and relaunch the app, the popup does not appear.

  • 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-22T23:52:37+00:00Added an answer on May 22, 2026 at 11:52 pm

    self.firstTimeLaunchingApp in initialized in viewDidLoad. After saving the key you have not refreshed it’s value. So when the method is called again, its value is not 1. It is still containing the value which was read before. There is no problem in saving, as after re-launching you are not seeing the alert. Do this:

    [prefs setInteger:1 forKey:@"firstTimeLaunchx"]; 
    [prefs synchronize];
    
    // add this line
    self.firstTimeLaunchingApp = [prefs integerForKey:@"firstTimeLaunchx"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to read a file and store the information in unsigned char
My Rails 3 app has a UserAction object that I use to store information
Hello iam trying to store sum information inside a SQL Server table , but
I am trying to store some DOM information into an Array so I can
I'm trying to store information on a form by using sessions in case the
Am trying to get some order information from XML file and trying to store
I'm trying to store some information using XML, what would be the correct method
Hey so I am trying to use Shared Preferences to store information that is
I am new to asp .net mvc3 I am trying to store additional user
I'm trying to store some encrypted (short) information in a cookie. I'm generating a

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.