Xcode: Compare two NSMutableArrays

2019-08-01 04:35发布

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条回答
叛逆
2楼-- · 2019-08-01 05:07

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

查看更多
登录 后发表回答