开发者

Xcode: Compare two NSMutableArrays

开发者 https://www.devze.com 2023-02-19 15:30 出处:网络
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 stru

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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消