Instance Method

enumerateObjectsWithOptions:usingBlock:

Executes a given block using each object in the array with the specified options.

Declaration

- (void)enumerateObjectsWithOptions:(NSEnumerationOptions)opts usingBlock:(void (^)(ObjectType obj, NSUInteger idx, BOOL *stop))block;

Parameters

opts

The options for the enumeration. For possible values, see NSEnumerationOptions.

block

The block to apply to elements in the array.

The block takes three arguments:

obj

The object.

idx

The index of the object in the array.

stop

A reference to a Boolean value. Setting the value to YES within the block stops further enumeration of the array. If a block stops further enumeration, that block continues to run until it’s finished. When the NSEnumerationConcurrent enumeration option is specified, enumeration stops after all of the currently running blocks finish.

Discussion

This method executes synchronously. By default, the enumeration starts with the first object and continues serially through the array to the last object. You can specify NSEnumerationConcurrent and/or NSEnumerationReverse as enumeration options to modify this behavior.

See Also

Sending Messages to Elements

- makeObjectsPerformSelector:

Sends to each object in the array the message identified by a given selector, starting with the first object and continuing through the array to the last object.

- makeObjectsPerformSelector:withObject:

Sends the aSelector message to each object in the array, starting with the first object and continuing through the array to the last object.

- enumerateObjectsUsingBlock:

Executes a given block using each object in the array, starting with the first object and continuing through the array to the last object.

- enumerateObjectsAtIndexes:options:usingBlock:

Executes a given block using the objects in the array at the specified indexes.

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