---
title: "init(length:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsmutabledata/init(length:)"
---

# init(length:)

Initializes and returns a mutable data object containing a given number of zeroed bytes.

## Declaration

```swift
init?(length: Int)
```

## Parameters

- `length`: The number of bytes the object initially contains.

## Return Value

Return Value An initialized NSMutableData object containing length zeroed bytes. The returned object has the same memory alignment guarantees as malloc(_:).

## See Also

### Creating Mutable Data

- [init(capacity:)](foundation/nsmutabledata/init(capacity:).md)
