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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:03:06+00:00 2026-05-23T19:03:06+00:00

I was looking to create plist file in my application Documents folder programmatically in

  • 0

I was looking to create plist file in my application Documents folder programmatically in objective C. I created a folder in documents directory :

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
NSString *path = [NSString stringWithFormat:@"%@/Data.plist", documentsDirectoryPath];

I am trying to create plist file which will look like an XML file.
/**** Required XML File ****/

<?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>
<dict>
    <key>height</key>
    <integer>4007</integer>
    <key>name</key>
    <string>map</string>
    <key>width</key>
    <integer>6008</integer>
</dict>
</array>
</plist>

/****Achieved file through code ****/

<?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>height</key>
    <string>4007</string>
    <key>name</key>
    <string>map</string>
    <key>width</key>
    <string>6008</string>
</dict>
</plist>

The required file needs an array and inside the array we have a dictionary object. How can I change this ?
I also know how to write the file to the path, but the major issue is how to create plist file and then read it ?

  • 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-23T19:03:07+00:00Added an answer on May 23, 2026 at 7:03 pm

    A PLIST file, also known as a “Property List” file, uses the XML format to store objects such as arrays, dictionaries, and strings.

    You can use this code for creating, adding the values and retrieving the values from the plist file.

    //Get the documents directory path
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"plist.plist"];
    NSFileManager *fileManager = [NSFileManager defaultManager];
    
    if (![fileManager fileExistsAtPath: path]) {
    
        path = [documentsDirectory stringByAppendingPathComponent: [NSString stringWithFormat:@"plist.plist"] ];
    }
    
    NSMutableDictionary *data;
    
    if ([fileManager fileExistsAtPath: path]) {
    
        data = [[NSMutableDictionary alloc] initWithContentsOfFile: path];
    }
    else {
        // If the file doesn’t exist, create an empty dictionary
        data = [[NSMutableDictionary alloc] init];
    }
    
    //To insert the data into the plist
    [data setObject:@"iPhone 6 Plus" forKey:@"value"];
    [data writeToFile:path atomically:YES];
    
    //To retrieve the data from the plist
    NSMutableDictionary *savedValue = [[NSMutableDictionary alloc] initWithContentsOfFile: path];
    NSString *value = [savedValue objectForKey:@"value"];
    NSLog(@"%@",value);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking to create a web.config file and I'm a little confused about which
Looking to create my first MVC application. Coming from WebForms I'm pretty excited to
I'm looking to create a rich-featured application using a client/server model, using WCF as
Im looking to create a web application using ASP.NET MVC or PHP (not decided
Im looking to create an input field on a web application that is similar
I am looking to create an application that will allow me to record from
I've created a plist (File->New File->Resource plist) file that has a dictionary that stores
I looking to create a custom calender with Zend Framework, I am hoping that
Im looking to create a control that would look like comic baloon. In WPF
I'm looking to create favicon.ico files programatically from Python, but PIL only has support

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.