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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:06:55+00:00 2026-06-10T07:06:55+00:00

I am using plists to save/load an NSMutableArray, the code: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,

  • 0

I am using plists to save/load an NSMutableArray,

the code:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *prsPath = [documentsDirectory stringByAppendingPathComponent:@"records.plist"];

prs = [[NSMutableArray alloc] initWithContentsOfFile:prsPath];

when I am using the last sentence of code somewhere else in my code it says: “prsPath” undeclared. (I am loading my code in ViewDidLoad) When I add an Object it doesn’t save it, it doesn’t even show up. (Loading the last sentence on add)

  • 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-06-10T07:06:56+00:00Added an answer on June 10, 2026 at 7:06 am

    I’m using this method and it’s work 100%

    - (void) writeToPlist: (NSString*)fileName withData:(NSMutableArray *)data
    {
         NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
         NSString *finalPath = [documentsDirectory stringByAppendingPathComponent:fileName];
    
         [data writeToFile:finalPath atomically: YES];
         /* This would change the firmware version in the plist to 1.1.1 by initing the NSDictionary with the plist, then changing the value of the string in the key "ProductVersion" to what you specified */
    }
    

    and this method for reading from plist file:

    - (NSMutableArray *) readFromPlist: (NSString *)fileName {
         NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
         NSString *finalPath = [documentsDirectory stringByAppendingPathComponent:fileName];
    
         BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:finalPath];
    
         if (fileExists) {
              NSMutableArray *arr = [[NSMutableArray alloc] initWithContentsOfFile:finalPath];
              return arr;
         } else {
              return nil;
         }
    }
    

    Hope it can help you.

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

Sidebar

Related Questions

I am trying to save an NSMutableArray containing text to a plist file using
I am getting comfortable with using plists for initializing my app. I now want
I am working on a game that makes use of a save/load feature. I
I have saved all my files using something like this NSString *fileName = [NSString
I'm using a NSDictionary to get a NSString from a plist with the following
I am trying to load my table view using plist file. But when i
I would like to define tasks using NSDictionary, which I'd like to save in
I am using a plist to store data that won't change. I load it
I'm using NSUserDefaults to save some data in my application. Where can I find
I've finally managed to save my data using NSCoding and a plist file. However,

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.