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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:38:47+00:00 2026-05-29T10:38:47+00:00

Using this code I am trying to get the data from Templates.plist file but

  • 0

Using this code I am trying to get the data from Templates.plist file but I am getting null value in array.

//from plist
NSString *path = [[NSBundle mainBundle] pathForResource:@"Templates" ofType:@"plist"];
NSMutableArray *arry=[[NSMutableArray alloc]initWithContentsOfFile:path];

NSLog(@"arrayArray:::: %@", arry);

This is my plist file:

Plist file

Also I want to know how can I add more strings to this plist file and delete a string from this plist.

  • 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-29T10:38:48+00:00Added an answer on May 29, 2026 at 10:38 am

    First off you cannot write to anything in you mainBundle. For you to write to you plist you need to copy it to the documents directory. This is done like so:

    - (void)createEditableCopyOfIfNeeded 
    {
         // First, test for existence.
         BOOL success;
    
         NSFileManager *fileManager = [NSFileManager defaultManager];
         NSError *error;
         NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
         NSString *documentsDirectory = [paths objectAtIndex:0];
         NSString *writablePath = [documentsDirectory stringByAppendingPathComponent:@"Template.plist"];
         success = [fileManager fileExistsAtPath:writablePath];
    
         if (success) 
             return;
    
         // The writable file does not exist, so copy from the bundle to the appropriate location.
         NSString *defaultPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Template.plist"];
         success = [fileManager copyItemAtPath:defaultPath toPath:writablePath error:&error];
         if (!success) 
             NSAssert1(0, @"Failed to create writable file with message '%@'.", [error localizedDescription]);
    }
    

    So calling this function will check if the file exists in the documents directory. If it doesn’t it copies the file to the documents directory. If the file exists it just returns. Next you just need to access the file to be able to read and write to it. To access you just need the path to the documents directory and to add your file name as a path component.

    NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSString *filePath = [docDir stringByAppendingPathComponent:@"Template.plist"];
    

    To get the data from the plist:

    NSMutableArray *array = [[NSMutableArray alloc] initWithContentsOfFile:filePath];
    

    To write the file back to the documents directory.

        [array writeToFile:filePath atomically: YES];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get some percentage data from a stored procedure using code
I'm using WSGI and trying to access the get/post data, using this code: import
I'm trying to get data from another domain using jQuery. Here is the code:
I am trying to parse the data I get from http://www.google.com/ig/api?weather=bangalore by using this
I'm trying to get data from a database using FMDB but having tried with
I've been using this code to try and get data from the google weather
I'm trying to get JSON data from facebook using the following code: var getFriends
Im trying to get pretty.js to prettify code in CODE tags, using this js:
I'm trying to parse a html doc using some code I found from this
I'm simply trying to get data from two sql server db tables using ado.net

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.