就像NSArray用来存储NSObject对象,只不过用于对象无序集合。NSArray是有序的。 用法如下:
//NSSet //Unordered collection of objects. //Immutable. You cannot add or remove objects to it once //it’s created. //Important methods: + setWithObjects:(id)firstObj, ...; // nil terminated - (int)count; - (BOOL)containsObject:(id)anObject; - (id)anyObject; - (void)makeObjectsPerformSelector:(SEL)aSelector; - (id)member:(id)anObject; // uses isEqual: and returns a matching object (if any) //NSMutableSet //Mutable version of NSSet. + (NSMutableSet *)set; - (void)addObject:(id)anObject; - (void)removeObject:(id)anObject; - (void)removeAllObjects; - (void)unionSet:(NSSet *)otherSet; - (void)minusSet:(NSSet *)otherSet; - (void)intersectSet:(NSSet *)otherSet;