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

# data(withCapacity:options:)

```
func data(withCapacity capacity: Int, options: IOUSBHostObjectDataOptions = []) throws -> NSMutableData
```

## Parameters

`capacity`

Size of the buffer to allocate

`options`

IOUSBHostObjectDataOptions. Default value is IOUSBHostObjectDataOptionsNone.

## Return Value

NSMutableData of memory mapped to user space of an IOBufferMemoryDescriptor if successful,
otherwise nil. An IOReturn error code will be reported on failure. The result is
to be released by the caller

## Discussion\abstract Allocate a buffer to be used for I/O or an isochronous frame list.
\discussion This method will allocate and map an IOBufferMemoryDescriptor optimized for use
by the underlying controller hardware. A buffer allocated by this method will not
be bounced to perform DMA operations.
Because the NSMutableData is backed by kernel memory, the length and capacity are
not mutable. Any changes to the length or capacity will cause an exception to be
thrown.

---

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)