A collection (nsset) object is a combination of Single-value objects. For example, a set of 1 to 50 numbers.
Operations on collection objects include searching, adding, and deleting members in a set, comparing two sets, and calculating the intersection and union of the two sets.
Common nsset methods:
+ (ID) setwithobjects: obj1, obj2, obj3 ,... nil // use a group of objects to create a new set-(ID) initwithobjects: obj1, obj2 ,... nil // use a group of objects to initialize the newly assigned set-(nsuinterger) Count // return the number of members of the Set-(bool) containsobject: OBJ // determine whether the set contains the object obj-(bool) Member: OBJ // determine whether the set contains the object obj-(nsenumerator *) objectenumerator // return all objects in the set to an nseumerator type object-(bool) issubsetofset: nsset // determine whether it is a subset of the nsset-(bool) intersectsset: nsset // determine whether there is at least one element in the intersection of the two sets // or: Determine whether there is at least one element in the collection in nsset-(BOO) isw.toset: nsset // determine whether two sets are equal
Common nsmutableset methods:
-(ID) setwithcapacity: Size-(ID) initwithcapacity: Size-(void) addobject: OBJ // Add an object to the Set-(void) removeobject: OBJ // Delete object obj-(void) removeallobjects from the set // delete all objects in the Set-(void) unionset: nsset // Add all elements of nsset to the set, that is, the Union set-(void) minusset: nsset // removes all nsset elements from the set-(void) interectset: nsset // sets and nsset for intersection operations, that is, intersection