---
title: length
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/nsmutabledata/length
---

# length

The number of bytes contained in the mutable data object.

## Declaration

```swift
var length: Int { get set }
```

## Discussion

Discussion The mutable data object’s length parameter is read-writeable. You can set this parameter to expand or truncate the number of bytes contained by the data object. If the mutable data object is expanded, the additional bytes are filled with zeros. important: Changing the length of a mutable data object invalidate any existing data pointers returned by the bytes or mutableBytes properties.

## See Also

### Related Documentation

- [increaseLength(by:)](foundation/nsmutabledata/increaselength(by:).md)
