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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:59:21+00:00 2026-05-25T18:59:21+00:00

I’m trying to save an array to a .plist file on my iphone but

  • 0

I’m trying to save an array to a .plist file on my iphone but it won’t save to it. When i try it on the simulator it works. But when i run it on the iphone it doesn’t work. I check if the file exists on the device and it does and i can read the data from the file, but it won’t write to it. Here is the code when i add the data to the .plist file.

//Sorts the arrays
    [self sortArrays];

    NSString *sString = [[NSString alloc] initWithFormat:@"Schema%i", currentIndex];
    NSString *daPath = [[NSBundle mainBundle] pathForResource:sString ofType:@"plist"];
    NSLog(@"Path: %@", daPath);

    //Checks if the file exists
    BOOL exists;
    NSFileManager *fileManager = [NSFileManager defaultManager];
    exists = [fileManager fileExistsAtPath:daPath];
    if(!exists)
        NSLog(@"PATH %@ DOES NOT EXIST", daPath);
    else
        NSLog(@"PATH %@ DO EXIST!!", daPath);

    //Writes out the array to check if it gots any elements
    for (int i = 0; i < [itemsArray count]; i++)
        NSLog(@"%i: %@", i, [(NSMutableArray*)[itemsArray objectAtIndex:i] objectAtIndex:0]);

    //Writes the array to the .plist
    [itemsArray writeToFile:daPath atomically:YES];

    //Gets the .plist file
    NSMutableArray *tmpA2 = [[NSMutableArray alloc] initWithContentsOfFile:daPath];

    //Checks if the new elements that got added is there.
    for (int i = 0; i < [tmpA2 count]; i++)
        NSLog(@"FILE: %i: %@", i, [(NSMutableArray*)[tmpA2 objectAtIndex:i] objectAtIndex:0]);

    [sString release];
    [itemsArray release];
    sString = nil;
    itemsArray = nil;

Does anyone know why it doesn’t work?

  • 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-25T18:59:22+00:00Added an answer on May 25, 2026 at 6:59 pm

    You can not write into the app bundle, you need to write to the app’s document directory.

    NSString *fileName = @"fileName";
    NSArray *searchPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentDirectoryPath = [searchPath objectAtIndex:0];
    NSString *filePath = [documentDirectoryPath stringByAppendingPathComponent:fileName]; 
    

    If there is initial data in a file in the app bundle on startup copy it to the document directory if it does not exist and then it can be read, modified and written..

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

Sidebar

Related Questions

I'm trying to save some settings from my app to a plist file when
I am trying to save an NSMutableArray containing text to a plist file using
I'm trying to save a simple string on a simple .plist file when the
I want to save to disk an array of objects as plist file .
I am trying to save data to a database on a button push, but
I'm trying to save a PDF file to SQL Server and I already have
I was trying to archive an object into a plist file and load it
I'm trying to implement a Save State for my iPhone App. I've got a
I am trying to save/write an Array to the documents directory, and I am
I'm trying to save an array to Core Data. I've been reviewing the following

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.