<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreTransferable",
  "identifier" : "/documentation/CoreTransferable/TransferRepresentation/exportingCondition(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Transferable",
      "CoreTransferable"
    ],
    "preciseIdentifier" : "s:16CoreTransferable22TransferRepresentationPAAE18exportingConditionyAA012_ConditionalcD0VyxGSb4ItemQzYbcF"
  },
  "title" : "exportingCondition(_:)"
}
-->

# exportingCondition(_:)

Prevents the system from exporting an item if it does not meet the supplied condition.

```
func exportingCondition(_ condition: @escaping @Sendable (Self.Item) -> Bool) -> _ConditionalTransferRepresentation<Self>
```

## Parameters

`condition`

A closure that determines whether the item is exportable.
Don’t perform long-running work in this closure.
It shouldn’t contain network requests, file operations,
or other potentially time-consuming tasks as they
can cause delays during operations with `Transferable` items.

## Discussion

Some instances of a model type may have state-dependent conditions that make them
unsuitable for export. For example, an `Archive` structure that supports
a comma-separated text representation only when it has compatible content:

```
struct Archive {
    var supportsCSV: Bool
    func csvData() -> Data
    init(csvData: Data)
}

extension Archive: Transferable {
    static var transferRepresentation: some TransferRepresentation {
        DataRepresentation(contentType: .commaSeparatedText) { archive in
            archive.csvData()
        } importing: { data in Archive(csvData: data) }
            .exportingCondition { archive in archive.supportsCSV }
    }
}
```

---

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)