S. Chand S. Chand - 24 days ago 25
Objective-C Question

How to remove duplicity from array of dictionaries in IOS?

(
{
color = blue;
},
{
color = blue;
},
{
color = red;
},
{
color = white;
}
)


This is an Array of dictionary, i have to remove duplicate dictionary from array corresponding to key color.

Answer

NSSet is to save you in this case. Use:

NSSet *set = [NSSet setWithArray:duplicateArray];
NSArray *uniqueArray = [set allObjects];

Avoid using loop for this because if you have more object loop is a consuming process. You can directly use NSSet and it will work for sure.

Comments