<!--
{
  "availability" : [
    "DriverKit: -",
    "iOS: -",
    "iPadOS: -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "DriverKit",
  "identifier" : "/documentation/DriverKit/OSData/withData-9y3g",
  "metadataVersion" : "0.1.0",
  "role" : "Static Method",
  "symbol" : {
    "kind" : "Static Method",
    "modules" : [
      "DriverKit"
    ],
    "preciseIdentifier" : "c:@S@OSData@F@withData#*1$@S@OSData#S"
  },
  "title" : "withData"
}
-->

# withData

Allocates an OSData object with a copy of bytes from another OSData.

```
static OSDataPtr withData(const OSData *inData);
```

## Parameters

`inData`

An OSData object to copy. The data will be copied at the time of the call.

## Return Value

NULL on failure, otherwise the allocated OSData with reference count 1 to be released by the caller.

---

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)