Instance Method

enumerateObjects(_:)

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

func enumerateObjects(_ block: (Any, Int, UnsafeMutablePointer<ObjCBool>) -> Void)

Parameters

block

The block to apply to elements in the array.

The block takes three arguments:

obj

The element in the array.

idx

The index of the element in the array.

stop

A reference to a Boolean value. The block can set the value to true to stop further enumeration of the array. If a block stops further enumeration, that block continues to run until it’s finished. The stop argument is an out-only argument. You should only ever set this Boolean to true within the block.

Discussion

If the block parameter is nil this method will raise an exception. Values allocated within the block will be deallocated after the block is executed. Use retain to explicitly maintain those values.

This method executes synchronously.

See Also