---
title: bytes
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/nsdata/bytes
---

# bytes

A pointer to the data object’s contents.

## Declaration

```swift
var bytes: UnsafeRawPointer { get }
```

## Discussion

Discussion If the length of the NSData object is 0, this property returns nil. For an immutable data object, the returned pointer is valid until the data object is deallocated. For a mutable data object, the returned pointer is valid until the data object is deallocated or the data is mutated.

## See Also

### Related Documentation

- [description](foundation/nsdata/description.md)

### Accessing Underlying Bytes

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