سؤال

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`
هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top