I have a record of 100 Electronic items with Categories in database, with every request I load 20 records in Table View. I want to merge 2 arrays into 3rd array
E.g.
1) NSMutableDictionary *prevResultSet;
2) NSMutableDictionary *newResultSet;
3) NSMutableDictionary *finalArray;
I tried using addEntriesFromDictionary but it overwrites the duplicate key instead of merging.
_finalArray = [[NSMutableDictionary alloc] init];
[_finalArray addEntriesFromDictionary:_prevResultSet];
[_finalArray addEntriesFromDictionary:_newResultSet];
_prevResultSet = {
LED = (
{
rate = "25,000";
type = Sony;
},
{
rate = "25,000";
type = Samsung;
},
);
LCD = (
{
rate = "15,000";
type = Samsung;
},
{
rate = "15,000";
type = Sony;
},
);
_newResultSet = {
LCD = (
{
rate = "15,000";
type = LG;
},
{
rate = "15,000";
type = Onida;
},
);
Current Output: (After using addEntriesFromDictionary:)
_finalArray = {
LED = (
{
rate = "25,000";
type = Sony;
},
{
rate = "25,000";
type = Samsung;
},
);
LCD = (
{
rate = "15,000";
type = LG;
},
{
rate = "15,000";
type = Onida;
},
);
Expected Output:
_finalArray = {
LED = (
{
rate = "25,000";
type = Sony;
},
{
rate = "25,000";
type = Samsung;
},
);
LCD = (
{
rate = "15,000";
type = Samsung;
},
{
rate = "15,000";
type = Sony;
},
{
rate = "15,000";
type = LG;
},
{
rate = "15,000";
type = Onida;
},
);
Thanks in advance...