Combine an array of objects for the same value in Objective-C iOS

Viewed 1256

I have an array of custom object name finalBarListArray with entity BarCodeSKULists (refer to the attachment 1) which contains sales_sub_category_name (string type), count (int type) and an array of another custom object name arrayBarCodeSKUList (BarCodeSKUList) (refer to the attachment 2/3/4).

Please see the below screenshots:

enter image description here

enter image description here

enter image description here

enter image description here

Now I need to create an array and have to check if there will be same sales_sub_category_name value then need to add their arrayBarCodeSKUList in one.

Like in above array finalBarListArray, there are three elements with sales_sub_category_name 'ENVY 17', 'ENVY 15' & 'ENVY 15', so I need to merge second and third element into one for second index of array. It means Output should have only two elements, where first element should have (count = 1 & one arrayBarCodeSKUList) and the second element should have (count = 2 & two arrayBarCodeSKUList).

2 Answers
Related