Xcode: Compare two NSMutableArrays

岁酱吖の 提交于 2020-01-06 02:18:08

问题


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.

Old Array:

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

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

New Array:

    <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>

Thanks.


回答1:


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



来源:https://stackoverflow.com/questions/5437173/xcode-compare-two-nsmutablearrays

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!