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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:56:22+00:00 2026-06-11T01:56:22+00:00

My plist is an array with dictionaries . At launch, the .plist is copied

  • 0

My plist is an array with dictionaries.

At launch, the .plist is copied from bundle to documents directory if it doesn’t exist there already.

But if the plist already exists in documents directory:

each dictionary must be checked against its updated twin dictionary in the bundle to look for changes in the “District” string.

And of course, replace the string if there has been made a change.

This is the copy plist function:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self copyPlist];
return YES;
}

- (void)copyPlist {

NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Wine.plist"];
NSString *bundle = [[NSBundle mainBundle] pathForResource:@"Wine" ofType:@"plist"];
NSFileManager *fileManager = [NSFileManager defaultManager];

if (![fileManager fileExistsAtPath: path]) {
    [fileManager copyItemAtPath:bundle toPath:path error:&error];
} else {
//I need to check if the "District" value has been changed in any of the dictionaries.
}
}

Any suggestion for how this could be done, or useful tutorials/sample codes?

My guess is that I have to extract the content of the plists into NSMutableArrays: bundleArray and documentsArray. Then find the matching dictionaries in the arrays. Could be done by looking at “Name” string to be equal. Then compare the two “District” strings in the matching dictionaries and look for any changes, and replace the changed ones. But I have no idea how it should be done so any help is very useful as this is very important!

  • 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-11T01:56:23+00:00Added an answer on June 11, 2026 at 1:56 am

    I think your Dictionary Structure is as follows:
    Root as “Array”

    1. Dictionary 1 with “District as one of the key”

    2. Dictionary 2 with “District as one of the key”

    You can check if two NSDictionary at particular indexes of Array are equal or not, which I have coded below.

    NSArray *bundleArray=[[NSArray alloc] initWithContentsOfFile:@"path to .plist in bundle"];;
    NSArray *documentArray=[[NSArray alloc] initWithContentsOfFile:@"path to .plist in DocumentDirectory"];
    BOOL updateDictionary=NO;
    
    for(int i=0;i<bundleArray.count;i++){
        NSDictionary *bundleDic=[bundleArray objectAtIndex:i];
    
        NSDictionary *documentDic=[documentArray objectAtIndex:i];
    
        if(![bundleDic isEqualToDictionary:documentDic])
        {
            /*
             *if there is any change between two dictionaries. 
             * i.e bundle .plist has changed so update .plist in document Directory
             */
    
            [documentDic setValue:[bundleDic objectForKey:@"District"] forKey:@"District"];
            updateDictionary=YES;
    
        }
    }
    
    //Update Dictionary
    if(updateDictionary){
        [documentArray writeToFile:@"path to .plist in DocumentDirectory" atomically:YES];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My plist array of dictionaries is copied from the bundle to the documents directory
Im copying the plist array of dictionaries to documents directory on the device like
I have an array of dictionaries loaded from a plist (below) called arrayHistory. <plist
I'm trying to display data from a plist that is an array of dictionaries:
I've been using the following to create an array from a plist of dictionaries:
I have a plist (array of dictionaries) which populates a table view and works
I have a plist file which is an array of dictionaries. Where each dictionary
I am using the method below to get an array from my plist and
I have a plist file which contains an array of dictionaries. Here is one
I have a dictionary of dictionaries and I have retrieved from a plist. Suppose

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.