Rewards = (
{
"Restaurant_ID" = 34;
"Rewarded_Points" = 40;
"Rewarded_Time" = "2015-11-23 09:16:00";
},
{
"Restaurant_ID" = 40;
"Rewarded_Points" = 60;
"Rewarded_Time" = "2015-11-24 12:22:56";
},
{
"Restaurant_ID" = 34;
"Rewarded_Points" = 40;
"Rewarded_Time" = "2015-11-24 12:22:56";
}
);
im retrieving above response to variable and show in TableViewController using for loop
for(int i=0;i<rewards.count;i++){
NSDictionary * rewardsObj = [rewards objectAtIndex:i];
restId = [rewardsObj objectForKey:@"Restaurant_ID"];
rewardedPoints = [rewardsObj objectForKey:@"Rewarded_Points"];
}
[self.tableView reloadData];
Current Output is showing same Restaurant ID again and again. i want if there is matching ID then those points need to be calculate sum.
34 - Total Points : 40
40 - Total Points : 60
34 - Total Points : 40 //Again
but i want to sort it like below
34 - Total Points : 80 // 40+40
40 - Total Points : 60