---
title: "ioData(withCapacity:)"
framework: iousbhost
role: symbol
role_heading: Instance Method
path: "iousbhost/iousbhostobject/iodata(withcapacity:)"
---

# ioData(withCapacity:)

Allocates a buffer for input/output requests.

## Declaration

```swift
func ioData(withCapacity capacity: Int) throws -> NSMutableData
```

## Parameters

- `capacity`: The size, in bytes, of the buffer to allocate.

## Return Value

Return Value A pointer to an allocated buffer.

## Discussion

Discussion This method allocates and maps a kernel buffer that the underlying controller hardware has optimized. Using this method, the buffer doesn’t bounce to perform DMA operations. important: Because the kernel backs the NSMutableData object, the length and capacity aren’t mutable. Any changes to the length or capacity throws an exception.
