如何从IOS中的字典数组中删除双重性? [英] How to remove duplicity from array of dictionaries in IOS?
本文介绍了如何从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.
推荐答案
NSSet
是为了保存你的情况。使用:
NSSet
is to save you in this case. Use:
NSSet *set = [NSSet setWithArray:duplicateArray];
NSArray *uniqueArray = [set allObjects];
避免使用循环,因为如果你有更多的对象循环是一个消耗过程。你可以直接使用 NSSet
,它肯定会有效。
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.
这篇关于如何从IOS中的字典数组中删除双重性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文