<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTAttachment/init(data:uniformTypeIdentifier:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:objc(cs)XCTAttachment(cm)attachmentWithData:uniformTypeIdentifier:"
  },
  "title" : "init(data:uniformTypeIdentifier:)"
}
-->

# init(data:uniformTypeIdentifier:)

Creates an attachment containing the provided data payload, with a custom UTI.

```
convenience init(data payload: Data, uniformTypeIdentifier identifier: String)
```

## Parameters

`payload`

The data to wrap as an attachment.

`identifier`

A custom UTI to represent the data’s content type.

## Discussion

Creates an attachment with a [`uniformTypeIdentifier`](/documentation/XCTest/XCTAttachment/uniformTypeIdentifier) of `"``public.data"`.

---

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)