I am trying to allow a user to send a pdf file using the SwiftUI ShareLink. However occasionally the pdf will not be available so the function that returns the pdf will be returning an optional URL. In this case when the user presses the share button I want to show an alert. Something like this:
Button {
if let url = render() {
// Present the share sheet to share the pdf
} else {
// Present an alert
}
} label: {
Image(systemName: "square.and.arrow.up")
}
//func render() returns an optional url
Is there anyway to achieve this without using a representable?