Reputation: 235
I want to share multiple PDF Documents with apples new ShareLink. I can share a single PDF Document by making my object transferable using the FileReprestation and giving my object into shareLink:
extension item: Transferable {
public static var transferRepresentation: some TransferRepresentation {
FileRepresentation(exportedContentType: .pdf) { item in
return SentTransferredFile(item.url, allowAccessingOriginalFile: false)
}
}
}
and using ShareLink in my view:
ShareLink(item: item, preview: SharePreview(Text(""))) {
Label("",systemImage: "square.and.arrow.up")
}
Another working option is giving ShareLink the URL of my PDF.
Now I want to share multiple PDF docs at the same time. I have an Array of Items ([Item]). Sadly ShareLink does not take and array of objects as input... How can I solve the problem?
Upvotes: 1
Views: 1075
Reputation: 1
you need to declare pdfs array and then pass it to 'items' argument
ShareLink(items: transferablePdfs, preview: { _ in
SharePreview("Share Title")
})
You can customize SharePreview for your needs. This sample code is just to show how pass multiple transferable items to ShareLink and share funcionality.
Upvotes: 0