Question

Any methods to add-on for the dictionary inside an array? I was trying to use

[[parentArray objectAtIndex:1] addEntriesFromDictionary:newDictionary];

but I get

*** Terminating app due to uncaught exception 'NSInvalidArgumentException, 'reason: '-[__NSDictionaryI addEntriesFromDictionary:]: unrecognized selector sent to instance`
Était-ce utile?

La solution

NSDictionary is immutable, and as such, has no such selector.

You want an NSMutableDictionary, which has the addEntriesFromDictionary: selector.

Or an NSMutableArray would allow you to grab the immutable dictionary, make a new immutable dictionary from that plus your new dictionary, and then store the combined immutable dictionary back at the index the original dictionary was originally at.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top