質問

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