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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:37:27+00:00 2026-05-14T01:37:27+00:00

I have a method that is called addHighScore. When a user wants to quit

  • 0

I have a method that is called addHighScore. When a user wants to quit the game, they can save their score out. In the resources folder, I created a highScore.plist and populated it with one entry. The structure is:

   item 1 (array)
      Name (dictionary, string)
      Level (dictionary, string)
      Score(dictionary, Number)

My problem is this: When I run this in the simulator, after I load the arrHighScores and then add the newScore dictionary, everything seems fine and the records get added (and shown via the NSLog statement) but this is ONLY as long as the app is running. Once I quit, go back in, the only entry that exists is the one I manually entered.

When I run this on the Device (iPhone), it never shows the records added, even while still in the game. I have looked at just about every example I can concerning NSDictionary and can’t seem to figure out what is going wrong.

Any Ideas or suggestions are greatly appreciated. Thanks in advance for any and all help. (Geo…)

My method looks like this:

 -(IBAction) addHighScore {
    NSString *myPath = [[NSBundle mainBundle] pathForResource:@"highScores" ofType:@"plist"];
    NSLog(@"myPath: %@", myPath);
    NSMutableArray *arrHighScores = [[NSMutableArray alloc] initWithContentsOfFile:myPath];

    NSMutableDictionary *newScore = [[NSMutableDictionary alloc] init];
    [newScore setValue:@"Geo" forKey:@"Name"];
    [newScore setValue:lblLevel.text forKey:@"Level"];
    [newScore setValue:[NSNumber numberWithDouble: dblScore] forKey:@"Score"];

    [arrHighScores addObject:newScore];

    for (int i = 0; i < [arrHighScores count]; i++) {
        NSLog(@"Retreiving (%d) --> %@", i, [arrHighScores objectAtIndex:i]);
    }

    [arrHighScores writeToFile:myPath atomically:YES];

    NSMutableArray *tmpArray2 = [[NSMutableArray alloc] initWithContentsOfFile:myPath];

    NSSortDescriptor *mySorter = [[NSSortDescriptor alloc] initWithKey:@"Score" ascending:YES];
    [tmpArray2 sortUsingDescriptors:[NSArray arrayWithObject:mySorter]];    

    for (int i = 0; i < [tmpArray2 count]; i++) {
        NSLog(@"Retreiving (%d) --> %@", i, [tmpArray2 objectAtIndex:i]);
    }

    [arrHighScores release];
    [tmpArray2 release];
    [mySorter release];
    [newScore release]; 

}
  • 1 1 Answer
  • 1 View
  • 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-14T01:37:28+00:00Added an answer on May 14, 2026 at 1:37 am

    The problem is that you are attempting to save your changes in application bundle but you don’t have permissions to write there. The correct place to save data is Documents directory in application sandbox – you can get it path:

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                 NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0];
    

    So the correct workflow should be:

    1. Try to load highscores data from Documents folder
    2. If file in Documents folder does not exist load data from resources
    3. Update data
    4. Save data to Documents folder

    See also “Commonly Used Directories” for more information about where you can and should save you application data.

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

Sidebar

Related Questions

I have an action method VerifyNewUser() that gets called when the user clicks a
I have a method that can be called if the person has a specific
I have this method that gets called when i press a button and removes
I have a form validation method that's called on submit. It executes a get
I have a method that accepts a sender and is called with a UIbutton.
I have a C# database layer that with static read method that is called
I have a method called ReadTill that has the same body of code but
I have a method, -(void)validateFormInput:(UITextField *)textField that gets called when the form's submit button
I have a Javascript function that is called from the onchange method in a
I have an interface (called Subject ) that has the following method: public void

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.