<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreTransferable",
  "identifier" : "/documentation/CoreTransferable/TransferRepresentation/suggestedFileName(_:)-47rg0",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Transferable",
      "CoreTransferable"
    ],
    "preciseIdentifier" : "s:16CoreTransferable22TransferRepresentationPAAE17suggestedFileNameyQrSSSg4ItemQzYbcF"
  },
  "title" : "suggestedFileName(_:)"
}
-->

# suggestedFileName(_:)

Provides a filename to use if the receiver chooses to write the item to disk.

```
func suggestedFileName(_ fileName: @escaping @Sendable (Self.Item) -> String?) -> some TransferRepresentation<Self.Item>
```

## Parameters

`fileName`

The optional closure that returns the suggested filename
including the filename extension.
If several suggested file names are specified on an item, only the last one will be used.

## Discussion

Any transfer representation can be written to disk.

```
struct Note: Transferable {
    var title: String
    var body: String
    static var transferRepresentation: some TransferRepresentation {
        ProxyRepresentation(exporting: \.body)
            .suggestedFileName { $0.title + ".txt" }
     }
 }
```

---

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)