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

The Archive Base Latest Questions

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

In my app I have a table view where the user presses an add

  • 0

In my app I have a table view where the user presses an “add” button in the nav bar and a new cell is added to the table view. The data from the table is loaded from an NSArray and each index in the array is storing an NSMutableDictionary with 4 Key-Value pairs. This array is saved to a .plist every time a cell is added. Now when the user selects a row in the table a detail view gets loaded. This detail view simply loads the data from the saved .plist depending on what row was selected.

In this detail view I want to allow the user to edit the data in the dictionary for that specific row. I’ve been trying different things and I can read the data from the dictionary and load it into the view but when I try and save the data back to the dictionary my app keeps terminating.

Can someone explain to me the proper way to reading and writing data to a an NSMutableDictionary?

This is how i’m writing the data back to the .plist:

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

NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
dict = [array objectAtIndex:selectedRow];

NSString *tempA = [[NSString alloc] initWithFormat:@"%d pts", ivar_A];
NSString *tempB = [[NSString alloc] initWithFormat:@"%d pts", ivar_B];
NSString *tempC = [[NSString alloc] initWithFormat:@"%d pts", ivar_C];

[dict setValue:tempA forKey:@"keyA"];
[dict setValue:tempB forKey:@"keyB"];
[dict setValue:tempC forKey:@"keyC"];

[tempA release];
[tempB release];
[tempC release];

[array insertObject:dict atIndex:selectedRow];

//Save the modified array back to the plist
[array writeToFile:[self dataFilePath] atomically:YES];

[dict release];

[array release];
  • 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-20T05:48:27+00:00Added an answer on May 20, 2026 at 5:48 am

    if you use [[NSMutableDictionary alloc] dictionaryFromContentsOfFile:@”pathtofile.plist], the contents of the dictionary will still be immutable, even if the top level container is mutable. It is specifically stated in Apple’s reference.

    NSDictionary Reference

    The dictionary representation in the
    file identified by path must contain
    only property list objects (NSString,
    NSData, NSDate, NSNumber, NSArray, or
    NSDictionary objects). For more
    details, see Property List Programming
    Guide. The objects contained by this
    dictionary are immutable, even if the
    dictionary is mutable.

    If you need to make the data structure writable again, you will need to make a copy of the loaded data structure using mutable types, like

    [NSMutableDictionary dictionaryWithDictionary:oOrig]
    

    etc.

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

Sidebar

Related Questions

So I have a table view that contains a bunch of data. The user
I have an app based on a tab bar and data retrieved from the
In my Ruby on Rails app, I have a User table and a Foo
For my iPhone app, I have an editable (for delete) table view. I'd like
I have an app that allows the user to move from a list of
I have a UINavigationController , complete with table view and associated magic. The data
I have an iphone app that uses table view as the interface. Each time
i have a table view that when the user taps on one of the
I'm new to Core Data. I'm creating an app that will allow a user
I am trying to make a simple web app. I have a User table

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.