Instance Method

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.

Declaration

- (void)enumerateObjectsUsingBlock:(void (^)(ObjectType obj, NSUInteger idx, BOOL *stop))block;

Parameters

block

The block to execute for each object 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.

Discussion

This method executes synchronously. Values allocated within the block are deallocated after the block is executed.

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.

enumerateObjectsWithOptions:usingBlock:

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

enumerateObjectsAtIndexes:options:usingBlock:

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