---
title: "enumerateBytes(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsdata/enumeratebytes(_:)"
---

# enumerateBytes(_:)

Enumerates each range of bytes in the data object using a block.

## Declaration

```swift
func enumerateBytes(_ block: (UnsafeRawPointer, NSRange, UnsafeMutablePointer<ObjCBool>) -> Void)
```

## Parameters

- `block`: The block to apply to byte ranges in the array. The block takes three arguments:

## Discussion

Discussion The enumeration block is called once for each contiguous region of memory in the receiver (once total for a contiguous NSData object), until either all bytes have been enumerated, or the stop parameter is set to true.

## See Also

### Accessing Underlying Bytes

- [bytes](foundation/nsdata/bytes.md)
- [getBytes(_:)](foundation/nsdata/getbytes(_:).md)
- [getBytes(_:length:)](foundation/nsdata/getbytes(_:length:).md)
- [getBytes(_:range:)](foundation/nsdata/getbytes(_:range:).md)
