Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top