There are two dictionaries like this, two dictionaries have same keys but different values.
/* dictionary 1 */
paramDict1 {
payAmount = 1000;
payType = 1;
}
/* dictionary 2 */
paramDict2 {
payAmount = 2000;
payType = 2;
}
I hope merge them to one dictionary like
paramDict {
payAmount = 1000;
payType = 1;
payAmount = 2000;
payType = 2;
}
Could you tell me how to do? Thanks.
Even if NSDictionary preserved the order of keys, which it does not, what you’re asking for is impossible because keys must be unique.
Instead, you could use an array of dictionaries:
Or perhaps less idiomatically, unique keys: