<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSMutableData/mutableBytes",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMutableData(py)mutableBytes"
  },
  "title" : "mutableBytes"
}
-->

# mutableBytes

A pointer to the data contained by the mutable data object.

```
var mutableBytes: UnsafeMutableRawPointer { get }
```

## Discussion

If the length of the receiver’s data is not zero, this property is guaranteed to contain a pointer to the object’s internal bytes. If the length of receiver’s data *is* zero, this property may or may not contain `NULL` dependent upon many factors related to how the object was created (moreover, in this case the method result might change between different releases). The returned pointer is valid until the data object is deallocated.

> Note:
> This property is similar to, but different than the ``doc://com.apple.foundation/documentation/Foundation/NSData/bytes`` property. The ``doc://com.apple.foundation/documentation/Foundation/NSData/bytes`` property contains a pointer to a constant. You can use The ``doc://com.apple.foundation/documentation/Foundation/NSData/bytes`` pointer to read the data managed by the data object, but you cannot modify that data. However, if the ``doc://com.apple.foundation/documentation/Foundation/NSMutableData/mutableBytes`` property contains a non-`null` pointer, this pointer points to mutable data. You can use the ``doc://com.apple.foundation/documentation/Foundation/NSMutableData/mutableBytes`` pointer to modify the data managed by the data object.

A sample using this method can be found in [Working With Mutable Binary Data](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/BinaryData/Tasks/WorkingMutableData.html#//apple_ref/doc/uid/20002150).

## See Also

[`bytes`](/documentation/Foundation/NSData/bytes)

A pointer to the data object’s contents.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)