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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:20:20+00:00 2026-06-03T04:20:20+00:00

I am writing an app that copies a plist into the docsdir and then

  • 0

I am writing an app that copies a plist into the docsdir and then reads it into a mutable array. The code below, however, returns a count of 0 for the array. The line with the dictionary log, however, returns the correct items. I have also verified that the file is being copied to the docsdir.

-(NSString *)docsDir {
    return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
}


- (void)viewDidLoad
{
    [super viewDidLoad];

    NSString *listPath = [[self docsDir]stringByAppendingPathComponent:@"list.plist"];
    if (![[NSFileManager defaultManager]fileExistsAtPath:listPath]) {
        [[NSFileManager defaultManager]copyItemAtPath:[[NSBundle mainBundle]pathForResource:@"list" ofType:@"plist"] toPath:listPath error:nil];
        NSLog(@"Chicken");
    }

    NSLog(@"%@", [NSDictionary dictionaryWithContentsOfFile:listPath]);
    _array = [NSArray arrayWithContentsOfFile:listPath];

    NSLog(@"Count: %i", [_array count]);

}

- (void)viewDidUnload
{
    [super viewDidUnload];
    / / Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
  • 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-03T04:20:21+00:00Added an answer on June 3, 2026 at 4:20 am

    Usually this is because by default root element in plist files is a Dictionary.

    Right click and select Open as Source Code, your file may look like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>foo</key>
        <array>
            <string>foo1</string>
            <string>foo2</string>
            <string>foo3</string>
        </array>
    </dict>
    </plist>
    

    where the root element is a dict, change it to:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <array>
        <string>foo1</string>
        <string>foo2</string>
        <string>foo3</string>
    </array>
    </plist>
    

    where the root element is an array. You can now edit as usual.

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

Sidebar

Related Questions

I'm writing an app that copies some contents of the bundle into the applications
i'm writing an app that needs a calculation support (Fun project). However, is there
I am writing an app that intercepts the launching of apps, killing them, then
I am writing an app that uses Highcharts, and in one instance I want
I am writing an app that plays a url using MPMoviePlayerController. The app works
I'm writing an app that has a view with nested UITableViews. The UITableViews in
I am writing an app that interfaces with the iPhone address book. Here is
I am writing an app that uses the TimeSpan object. Specifically I am using
I am writing an App that will allow users to browse through all files
We are writing an app that will use T4 to generate Flex/Actionscript to compile

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.