<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MessageUI",
  "identifier" : "/documentation/MessageUI/MFMessageComposeViewController/addAttachmentData(_:typeIdentifier:filename:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Message UI"
    ],
    "preciseIdentifier" : "c:objc(cs)MFMessageComposeViewController(im)addAttachmentData:typeIdentifier:filename:"
  },
  "title" : "addAttachmentData(_:typeIdentifier:filename:)"
}
-->

# addAttachmentData(_:typeIdentifier:filename:)

Attaches arbitrary content to the message.

```
func addAttachmentData(_ attachmentData: Data, typeIdentifier uti: String, filename: String) -> Bool
```

## Parameters

`attachmentData`

Content in the form of an <doc://com.apple.documentation/documentation/Foundation/NSData> object to attach to the message. Must not be `nil`.

`uti`

A valid Uniform Type Identifier (UTI) appropriate for the attachment data. See [Uniform Type Identifiers Reference](https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Introduction/Introduction.html#//apple_ref/doc/uid/TP40009257). Must not be `nil`.

`filename`

The name to present to the user, in the message UI, for the data attachment.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the attachment data was successfully added to the message, or <doc://com.apple.documentation/documentation/Swift/false> otherwise.

## Discussion

This method is especially useful when the attachment you want to add to a message does not have a file system representation. This can be the case, for example, for programmatically composed audiovisual content.

---

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)