---
title: "init(data:uniformTypeIdentifier:)"
framework: xctest
role: symbol
role_heading: Initializer
path: "xctest/xctattachment/init(data:uniformtypeidentifier:)"
---

# init(data:uniformTypeIdentifier:)

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

## Declaration

```swift
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

Discussion Creates an attachment with a uniformTypeIdentifier of "``public.data".

## See Also

### Creating Attachments from Data

- [init(data:)](xctest/xctattachment/init(data:).md)
- [init(uniformTypeIdentifier:name:payload:userInfo:)](xctest/xctattachment/init(uniformtypeidentifier:name:payload:userinfo:).md)
