Xcode:比较两个 NSMutableArrays [英] Xcode: Compare two NSMutableArrays

查看:50
本文介绍了Xcode:比较两个 NSMutableArrays的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个包含 Dictionary 对象的 NSMutableArrays(从 plist 文件内容初始化).任何人都可以帮助我用最好的方法来实现以下结果.Array的结构是:

I have two NSMutableArrays(initialized from plist file contents) that contains Dictionary objects. Could anyone please help me with the best method to achieve following result. The structure of Array is:

我想比较以下两个数组以获取新数组中不存在的旧条目.

I want to compare two following arrays to get the old entries which is not exists in new array.

旧数组:

    <dict>
        <key>ResourceId</key>
        <string>352</string>
    </dict>

    <dict>
        <key>ResourceId</key>
        <string>3115</string>
    </dict> 

新数组:

    <dict>
        <key>ResourceId</key>
        <string>352</string>
    </dict>

    <dict>
        <key>ResourceId</key>
        <string>4629</string>
    </dict>

我希望结果数组包含以下条目:

I want the resulted array contains following entry:

    <dict>
        <key>ResourceId</key>
        <string>3115</string>
    </dict>

谢谢.

推荐答案

将 NSMutableArray 转换为 NSMutableSet 对象,然后使用 Intersect 方法应该是最好的..

Converting NSMutableArray to NSMutableSet objects and then using Intersect method should be the best one..

这篇关于Xcode:比较两个 NSMutableArrays的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆