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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:27:12+00:00 2026-05-24T06:27:12+00:00

In my project AppDelegate file, I have an int declared called correctAnswersCountR1. So in

  • 0

In my project AppDelegate file, I have an int declared called correctAnswersCountR1. So in the app they take a small quiz and that variable keeps track of how many correct answers they got. Now somewhere else in the project I use this variable like so:

int r1score=appDelegate.correctAnswersCountR1;

The problem is that apparently if I exit the app and come back, the value isn’t remembered, and is set back to its default value. How can I store this number so that it is remembered if the user closes the app and comes back?

  • 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-24T06:27:15+00:00Added an answer on May 24, 2026 at 6:27 am

    You can use NSUserDefaults to store your value:

    **Saving**
    //Do this right before the app exits
    NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
    
    // saving an NSInteger
    [prefs setInteger:42 forKey:@"integerKey"];
    
    // This is suggested to synch prefs, but is not needed
    [prefs synchronize];
    
    **Retrieving**
    //Do this when your app is loaded again
    NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
    
    // getting an NSInteger
    NSInteger myInt = [prefs integerForKey:@"integerKey"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQlite database file with records which comes with my app. I
I have an application that works fine in an older project (that doesn't use
i have 15 to 20 Variable i wants access it in my whole project.
I have a MacRuby app that is meant to be customized and distributed by
I have a basic PhoneGap project, 100% auto-generated code. The app starts, and immediately
I've got an iphone project that I've added a .c file and corresponding .h
I have this weird problem.. I'm building an in-house app that should register all
I have an iPad project structured as: - AppDelegate - MainWindow - View Controller
I have an Xcode project which basically loads and parses a xml file which
I have downloaded an Xcode project that has three xibs (A.xib, B.xib, and C.xib).

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.