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

  • Home
  • SEARCH
  • 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 8686153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:46:19+00:00 2026-06-12T22:46:19+00:00

In my project I have to load a number of json files. I parse

  • 0

In my project I have to load a number of json files. I parse them with JSONKit and after every single parsing with

NSMutableDictionary *json = [myJSON objectFromJSONString]; 

I add them to an array like:

[self.themeArray addObject:json];

This works fine so far. Now I need to pass the dictionaries arround between views. Works so far as well, but I need to add few more objects to the dictionary object-> json. Even it I declared json as NSMutableDictionary it does not allow me to add objects as it seems the JSONKit parser creates non-mutable dictionaries.

I was thinking about creating an object which contains the json dictionary and my additional data side by side so I wouldn´t have to change the json dictionary. I could even change it to NSDictionary because there is no need to change it. But that seems somehow not-elegant to me.

Do you have any idea how I can solve this issue without changing the JSONKit lib?

Thanks in advance!

EDIT

i just tried after changing my code to

NSMutableDictionary *json = [[myJSON objectFromJSONString] mutableCopy];

something like this

[[self.theme objectForKey:@"theme"]  setObject:sender forKey:@"sender"];
[[self.theme objectForKey:@"theme"]  setValue:sender forKey:@"sender"];

Xcode throws an exception:

* Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘* -[JKDictionary setObject:forKey:]: mutating method sent to immutable object’

I assume that´s due to the fact there are still nested dictionaries in the superior dictionary. Then i would have to interate through my json object to copy all dictionaries to mutable dictionaries, right?

Perhaps it’s better to switch to NSJSONSerialization as suggested by Guillaume.

EDIT

I just tried something like this

[self.theme  setValue:sender forKey:@"sender"];

And it works now! It was as i assumend. Only the json object was copied to a mutable object. Probably obvious to you, it was not to me.

Thank you all for your help!

EDIT

Finally i changed my code again after i could not manage to change all objects deep inside my dictionary data to mutable objects. I threw out JSONKit and use now NSJSONDeserialization as recommendet here with the option NSJSONReadingMutableContainers. My code looks now like this and all containers (arrays and dictionaries) are mutable deep inside too. That makes me happy! 😉

NSMutableDictionary *json = [NSJSONSerialization JSONObjectWithData:myJSON options:NSJSONReadingMutableContainers error:&jsonParsingError];
  • 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-12T22:46:22+00:00Added an answer on June 12, 2026 at 10:46 pm

    You can always create mutable versions of objects from their non-mutable counterparts by copying them.

    NSMutableDictionary* json = [[myJSON objectFromJSONString] mutableCopy];
    

    It is not optimal, but copying smaller dictionaries does is usually not noticable from a performance point of view.

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

Sidebar

Related Questions

The Junits I have in my project need to load property files from the
I have a project where i load a number of objects from a web
I am developing an android project in which I have to load from group
So in Code::Blocks in Ubuntu (latest). I have a project in which I load
I have a test project in which I needs to load an XLSX file.
I have project asp.net with namespace test and I'm using resources (files Resource.resx and
I have a django project that uses a postgres db with a number of
I have an application where I query a database and load a large number
I have a working Play Framework project. I'm using Play Framework version number 1.2.5
I have a very simple project. Extremely watered down. All it does is load

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.