<!--
{
  "availability" : [
    "macCatalyst: 14.0.0 -",
    "macOS: 10.15.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "IOUSBHost",
  "identifier" : "/documentation/IOUSBHost/IOUSBHostObject/ioData(withCapacity:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "IOUSBHost"
    ],
    "preciseIdentifier" : "c:objc(cs)IOUSBHostObject(im)ioDataWithCapacity:error:"
  },
  "title" : "ioData(withCapacity:)"
}
-->

# ioData(withCapacity:)

Allocates a buffer for input/output requests.

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

## Parameters

`capacity`

The size, in bytes, of the buffer to allocate.

## Return Value

A pointer to an allocated buffer.

## 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 <doc://com.apple.documentation/documentation/Foundation/NSMutableData> object, the length and capacity aren’t mutable. Any changes to the length or capacity throws an exception.

---

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)