I am trying to share a formatted version of an array of structs.
if #available(iOS 16.0, *) {
ShareLink(item: observedObject.toFormattedString())
} else {
// Fallback on earlier versions
}
However, I get a Thread 1: EXC_BAD_ACCESS (code=1, address=0xab849c4e0c41cdb0)
when launching the app and the array (stored with @AppStorage) isn't empty.
Is there a way to accomplish the equivalent of passing a function to ShareLink
that only gets called when the Share button is pressed?
ShareLink(item: {
observedObject.toFormattedString()
})
I tried this code but nothing happens. (edit: it works if the sheet isn't in a toolbar)
Edit: The issue is with String(format: "%s %s %s", a, b, c)
, there are no crashes if I use "\(a) \(b) \(c)"
.