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`
Was it helpful?

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top