I have 2 NSSet's, say SetA and SetB.

SetA has 3 objects. SetA = @[ObjectA, ObjectB, ObjectC];

SetB has 4 objects. SetB = @[ObjectA, ObjectC, ObjectD, ObjectE];

I wish to find out which objects of SetA are missing in SetB. One way I can do it is by iterating over every object in SetA and finding it in SetB.

Question - Is there a quicker way to achieve this in which I don't have to iterate over the entire set. The sets are dynamically populated.

有帮助吗?

解决方案

Use NSMutableSet and minusSet to remove elements in another set. The difference is what you're looking for.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top