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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:44:14+00:00 2026-05-18T07:44:14+00:00

I have typed the coding under the highscore button. It is suppose to string

  • 0

I have typed the coding under the highscore button. It is suppose to string the text(name) in the textbox and save the highscore. However, i could not find any plist being created under the document. Please help

-(IBAction)savehighscore_button {


 int i, ii = -1;

 struct high_score {
  NSString *name;
  int highScore;
 };

 struct high_score structArray[10];

 NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];

 for (i=0; i<10; i++) {

  if ([userPreferences stringForKey :[NSString stringWithFormat:@"highScoreNameEntry%d",i]]!=nil && [userPreferences stringForKey :[NSString stringWithFormat:@"highScoreEntry%d"]]!=nil) {
  structArray[i].name= [userPreferences stringForKey:[NSString stringWithFormat:@"highScoreNameEntry%d",i]];
   structArray[i].highScore = [userPreferences integerForKey:[NSString stringWithFormat:@"highScoreEntry%d",i]];
   ii = i;
  }
 }
 if (myScore >0) {
  for (i==ii; i>=0; i--) {
   if (myScore > structArray[i].highScore) {
    if (i<9) {
     structArray[i+1] = structArray[i];
     structArray[i].name = nametextbox.text;
     structArray[i].highScore = myScore;

     if (i==ii && i<9) {
      structArray[i+1].name = nametextbox.text;
      structArray[i+1].highScore = myScore;
      ii=i+i;
     }

     else if(i==ii && i<9) {
      structArray[i+1].name = nametextbox.text;
      structArray[i+1].highScore = myScore;
      ii=i+1;
     }
    }
   }

   if (ii==-1 && myScore >0) {
    structArray[0].name = nametextbox.text;
    structArray[0].highScore = myScore;
    ii=0;
   }
   for (i=0; i<=ii; i++) {
    [userPreferences setObject:structArray[i].name forKey:[NSString stringWithFormat:@"highScoreNameEntry%d",i]];
    [userPreferences setInteger:structArray[i].highScore forKey:[NSString stringWithFormat:@"highScoreEntry%d",i]];
   }
  }
 }

}
  • 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-18T07:44:15+00:00Added an answer on May 18, 2026 at 7:44 am
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *writablePlistPath = [documentsDirectory stringByAppendingPathComponent:@"My.plist"];
    
    if(![[NSFileManager defaultManager]fileExistsAtPath:writablePlistPath]){
            BOOL success;
            NSString *defaultPlistPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"My.plist"];
            success = [[NSFileManager defaultManager] copyItemAtPath:defaultPlistPath toPath:writablePlistPath error:nil];
                   //for getting content of plist
            pListArray = [NSArray arrayWithContentsOfFile:writablePlistPath];
    }
    

    This code used for saving your plist in document directory so first time(at launch app first time on simulator or device) save your pList in document directory then you can access data of plist.by the same code change occur in if condition only ! opertor should not be there and pListArray have your pList data so you can access via this array.

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

Sidebar

Related Questions

My pages contain German characters and I have typed the text in between the
So, I'm working under the assumption that we have typed languages because we make
Okay here's the program I have typed up(stdio.h is included also): /* function main
I am developing an application using MVC Preview 5. I have used typed views.
I have a strongly-typed MVC View Control which is responsible for the UI where
I have a strongly typed user control (partial) and I'd like to be able
I have a quick question about fetching results from a weakly typed cursor and
We have our own ORM we use here, and provide strongly typed wrappers for
I have a problem with binding data using BindingSource, typed dataset and DataGridView. My
As the questions says I have always believed that a strongly typed list is

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.