One Logo Pool Ball
CoreTransferable · IOS API REFERENCE

FileRepresentation

struct · iOS 16.0+ · SDK 27.1

struct FileRepresentation<Item> where Item : Transferable

A transfer representation for types that transfer as a file URL. Use a ``FileRepresentation`` for transferring types that involve a large amount of data. For example, if your app defines a `Movie` type that could represent a lengthy video, use a `FileRepresentation` instance to transfer the video data to another app or process. struct Movie: Transferable { let url: URL static var transferRepresentation: some TransferRepresentation { FileRepresentation(contentType: .mpeg4Movie) { movie in SentTransferredFile(movie.url) } importing: { received in let copy = URL(fileURLWithPath: "<#...#>") try FileManager.default.copyItem(at: received.file, to: copy) return Self(url: copy) } } } Note that the overall recommendation is to specify the content type that describes the file content as close as possible. For example, if you are sharing a PDF file, declare a ``FileRepresentation`` of a ``UTType.pdf`` content type, instead of ``UTType.fileURL`` or ``UTType.content`` so the data can be dragged, shared, or imported to apps that support that data type: struct PDFDocument: Transferable { var file: URL static var transferRepresentation: some TransferRepresentation { FileRepresentation(contentType: .pdf) { ... } importing: { ... } } } It's efficient to pass data around as a file and the receiver loads it into memory only if it's required.

Members (0)

This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.

Skipped declarations

No declarations were skipped in this snapshot.

All CoreTransferable types →