0

i got an array in every element of this array is a dictionary and every dictionary there are some arrays.

it's like that

[ { [ ] }, { [ ] } ]

this is the schema i got from a server response.

here's my problem , when i try to change something i got

[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object

so what's the best approach for this ? i need to loop through all items to make them mutable? or is there any other method? because when i call mutable copy method , it just convert the outer layer to mutable.

any help will be appreciated..

iremk
  • 677
  • 1
  • 5
  • 16
  • You got a server response. Was it JSON? `NSJSONSerialization` class lets you create mutable containers when parsing it. – Eimantas Jul 12 '12 at 07:07
  • yeah its JSON response. could you please give an example? – iremk Jul 12 '12 at 07:11
  • It's just a single method call. Please see the documentation for `NSJSONSerialization` class: https://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html – Eimantas Jul 12 '12 at 07:17

1 Answers1

0

The TouchJSON library has an option to create mutable containers from JSON input.

Check this answer on stackoverflow for an example of how to setup TouchJSON's CJSONDeserializer object to create the mutable output.

Community
  • 1
  • 1
EeKay
  • 6,494
  • 3
  • 24
  • 24