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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:34:45+00:00 2026-05-30T11:34:45+00:00

I have a property list which I read into an NSDictionary, from which I

  • 0

I have a property list which I read into an NSDictionary, from which I would like to create a mutable copy into an NSMutableDictionary to edit the contents and – later be able to reset the mutable dictionary by copying back the original contents.

NSDictionary *defaultRows;
NSMutableDictionary *rows;

NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Config" ofType:@"plist"];
defaultRows = [[[NSDictionary alloc] initWithContentsOfFile: plistPath] objectForKey:@"rows"];

This is how I try to create a copy of the original dictionary (according to Apple’s recommendation):

rows = [NSMutableDictionary dictionaryWithDictionary: defaultRows];

When I try to change the contents of the dictionary rows with:

[[[rows objectForKey:self.company.coaTypeCode] objectForKey:statementType] removeObjectsAtIndexes:rowsToDelete];

I get the runtime error *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object'.

I have read the article here, but wonder if there is a more elegant method to implement a deep copy?

  • 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-30T11:34:47+00:00Added an answer on May 30, 2026 at 11:34 am

    Since you are loading defaultRows from a property list, the easiest way to do this is to just deserialize the property list with mutable containers.

    NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Config" ofType:@"plist"];
    NSData *rowsData = [NSData dataWithContentsOfFile:plistPath];
    
    NSMutableDictionary *rows = [NSPropertyListSerialization propertyListWithData:rowsData
        options:NSPropertyListMutableContainers format:NULL error:NULL];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does a List have a property or mechanism by which I can prevent duplicate
I have a List<MyClass> with 2 items which have a SequenceNumber property. If I
I have some classes like Client, Employee, Property I am maintaining the list of
I have a TListView descendant which introduces additional features like sorting and loading from
I have JTable which elements property binded to List of objects, this is master
i have a doubt in grid view. In Data list we have a property
I have a boolean property IsActive. In the view is a list of objects
I have a list of objects with property id and parent_id. I want to
I have a List<NameClass> that stores a collection of NameClass items with a property
I have a property of type uint on my entity. Something like: public class

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.