Instance Method

filter(using:)

Evaluates a given predicate against the set’s content and removes from the set those objects for which the predicate returns false.

Declaration

func filter(using predicate: NSPredicate)

Parameters

predicate

A predicate.

Discussion

The following example illustrates the use of this method.

NSMutableSet *mutableSet =
    [NSMutableSet setWithObjects:@"One", @"Two", @"Three", @"Four", nil];
NSPredicate *predicate =
    [NSPredicate predicateWithFormat:@"SELF beginswith 'T'"];
[mutableSet filterUsingPredicate:predicate];
// mutableSet contains (Two, Three)

See Also

Adding and removing entries

func add(Any)

Adds a given object to the set, if it is not already a member.

func remove(Any)

Removes a given object from the set.

func removeAllObjects()

Empties the set of all of its members.

func addObjects(from: [Any])

Adds to the set each object contained in a given array that is not already a member.

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