Type Method

setWithObjects:

Creates and returns a set containing the objects in a given argument list.

Declaration

+ (instancetype)setWithObjects:(ObjectType)firstObj, ...;

Parameters

firstObj

The first object to add to the new set.

firstObj, ...

A comma-separated list of objects, ending with nil, to add to the new set. If the same object appears more than once in the list of objects, it is added only once to the returned set. Each object receives a retain message as it is added to the set.

Return Value

A new set containing the objects in the argument list.

Discussion

As an example, the following code excerpt creates a set containing three different types of elements (assuming aPath exits):

NSSet *mySet;
NSData *someData = [NSData dataWithContentsOfFile:aPath];
NSValue *aValue = [NSNumber numberWithInteger:5];
NSString *aString = @"a string";
 
mySet = [NSSet setWithObjects:someData, aValue, aString, nil];

See Also

Creating a Set

+ set

Creates and returns an empty set.

+ setWithArray:

Creates and returns a set containing a uniqued collection of the objects contained in a given array.

+ setWithObject:

Creates and returns a set that contains a single given object.

+ setWithObjects:count:

Creates and returns a set containing a specified number of objects from a given C array of objects.

+ setWithSet:

Creates and returns a set containing the objects from another set.

- setByAddingObject:

Returns a new set formed by adding a given object to the receiving set.

- setByAddingObjectsFromSet:

Returns a new set formed by adding the objects in a given set to the receiving set.

- setByAddingObjectsFromArray:

Returns a new set formed by adding the objects in a given array to the receiving set.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software