In my app I have a class Person
with personId
property.
Now I need some data structure to hold a bunch of unique Person
objects (unique = different personId)
So I guess I should use NSMutableSet as my data structure, but how do I make the NSMutableSet compare the personId
property when adding a person (so I won't add the same person more then ones)?
My goal is to have a collection of unique persons all the time (even if I add two persons with the same id), I want that the NSMutableSet will do all the hard work for me and if I'm adding a person that already exists it won't add it twice.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…