Instance Method

objectsPassingTest:

Returns a set of object that pass a test in a given block.

Declaration

- (NSSet<ObjectType> *)objectsPassingTest:(BOOL (^)(ObjectType obj, BOOL *stop))predicate;

Parameters

predicate

The block to apply to elements in the array.

The block takes two arguments:

obj

The element in the set.

stop

A reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the block.

The block returns a Boolean value that indicates whether obj passed the test.

Return Value

An NSSet containing objects that pass the test.

See Also

Accessing Set Members

allObjects

An array containing the set’s members, or an empty array if the set has no members.

- anyObject

Returns one of the objects in the set, or nil if the set contains no objects.

- containsObject:

Returns a Boolean value that indicates whether a given object is present in the set.

- filteredSetUsingPredicate:

Evaluates a given predicate against each object in the receiving set and returns a new set containing the objects for which the predicate returns true.

- makeObjectsPerformSelector:

Sends a message specified by a given selector to each object in the set.

- makeObjectsPerformSelector:withObject:

Sends a message specified by a given selector to each object in the set.

- member:

Determines whether a given object is present in the set, and returns that object if it is.

- objectEnumerator

Returns an enumerator object that lets you access each object in the set.

- enumerateObjectsUsingBlock:

Executes a given block using each object in the set.

- enumerateObjectsWithOptions:usingBlock:

Executes a given block using each object in the set, using the specified enumeration options.

- objectsWithOptions:passingTest:

Returns a set of object that pass a test in a given block, using the specified enumeration options.

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