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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:16:51+00:00 2026-05-26T05:16:51+00:00

Currently, I have a tableView which is loaded from the following array called exerciseArray

  • 0

Currently, I have a tableView which is loaded from the following array called exerciseArray:

if (exerciseArray == nil)
    {
        NSString *path = [[NSBundle mainBundle]pathForResource:@"data" ofType:@"plist"];
        NSMutableArray *rootLevel = [[NSMutableArray alloc]initWithContentsOfFile:path];
        self.exerciseArray = rootLevel;
        [rootLevel release];
    }

However, I want an option to let the user add their own data which will need to be displayed in this same table view. I can either add that data to the original plist but I think it will be better to create a separate plist that will have the user added data.

So after the user adds data, the I will need to combine the 2 plist data next time. Any idea how to implement this? The user added data will need to match up with original plist structure which looks like:

enter image description here

The new plist should only have ExerciseName and musclename, but I need to merge the two somehow.

  • 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-26T05:16:51+00:00Added an answer on May 26, 2026 at 5:16 am

    The user-defined Property List should be stored in a file somewhere in the Documents directory. Usually, for something like this, I would suggest creating a copy of the default Plist that ships with the app to the Documents directory, then modifying and loading this file as needed. Copying the resource to the documents directory can be done as follows:

    NSString * documentsPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    NSString * docPlist = [documentsPath stringByAppendingPathComponent:@"data.plist"];
    if (![[NSFileManager defaultManager] fileExistsAtPath:docPlist]) {
        NSString * resPlist = [[NSBundle mainBundle]pathForResource:@"data" ofType:@"plist"];
        [[NSFileManager] defaultManager] copyItemAtPath:resPlist
                                                 toPath:docPlist
                                                  error:nil];
    }
    NSMutableArray * root = [[NSMutableArray alloc] initWithContentsOfFile:docPlist];
    

    The above code simply finds the path to the plist in the documents directory, and checks if it exists. If it does not, it copies the data.plist resource over to the documents directory. Once this is done, it loads the root element into a mutable array, which you can then use and modify using the standard addObject: and removeObject: methods.

    Finally, to save any modified data, simply write the root array back to the plist file as follows:

    [root writeToFile:docPlist atomically:YES];
    

    The only delemma with this is, while in the process of developing the app, you may wish to change or modify some data in the data.plist resource. In order for the app to copy this newly modified Property List to the documents directory, you will need to uninstall it completely from the iOS Simulator, then re-compile and run.

    Edit: In order to add an exercise to an existing muscle, just do something like this:

    // find the exercise dictionary
    int muscleIndex = 0;
    NSMutableDictionary * muscleDict = nil;
    NSString * muscleName = @"Neck";
    NSString * exerciseName = @"Nod your head a billion times";
    // find the right muscle
    for (int i = 0; i < [root count]; i++) {
        NSDictionary * muscle = [root objectAtIndex:i];
        if ([[muscle objectForKey:@"muscleName"] isEqualToString:muscleName]) {
            muscleIndex = i;
            muscleDict = [NSMutableDictionary dictionaryWithDictionary:muscle];
        }
    }
    
    NSMutableArray * exercises = [NSMutableArray arrayWithArray:[muscleDict objectForKey:@"exercises"]];
    [exercises addObject:exerciseName];
    [muscleDict setObject:exercises forKey:@"exercises"];
    [root replaceObjectAtIndex:muscleIndex withObject:muscleDict];
    ...
    // save root here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a functioning in-house Windows Forms application which extensively uses the DataGridView
I currently have a TableView inside a NavigationController where when a item is selected
I currently have a tabview with 3 tabs. 1 tab loads an ActivityGroup which
I have the following code, which connects to a web service and returns an
Is there an easy way to do the following: I have an application which
I have a TableView in which I can scroll to view all the rows.
I have created an app which is approved by apple and currently buyable in
The following method loads data from an array into custom cells of UITableView. The
I am currently developing an iPhone application which loads data from an RSS feed
Hi I currently have a table view which is being filled via Core Data.

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.