iOS, NSMutableDictionary

The problem is in the way you have defined your property. If you change it to:

@property (strong, nonatomic) NSMutableDictionary *DataDict ;

instead of copy everything should be fine.

This happens because you basically say that you want a copy of your object through your generated accessors, which returns an NSDictionary instead (an immutable copy).

You can find more on objective-c properties here.

Just as a sidenote: objective-c ivars usually start with a lowercase letter (uppercase names are used for classes), so dataDict should be preferred over DataDict.


It is because the property have "copy" attribute so NSMutableDictionary instance alloc/init-ed is "copy"'ed using "copy" method, and "copy" method create not NSMutableDictionary but NSDictionary. ("mutableCopy" will create NSMutableDictionary).

Probably, you can use "retain" instead of "copy" as attributes.

@property (retain, nonatomic) NSMutableDictionary *DataDict ;

Or, just without "copy"/"retain" but use ARC.(Automatic reference counting).