I think my biggest gripe with SwiftUI is that it's too easy to "hold it wrong"
Fixed an issue that was troubling me for the past couple short working sessions:
presenting an editable form that takes an [@]Binding with the sheet modifier requires some binding projection shenanigans. However the set closure was causing my sheet to dismiss then reappear, then dismiss again.
After commenting out the set closure entirely it works... but why?
1/
=> More informations about this toot | More toots from bens@mastodon.xyz
It's because I'm using SwiftData and the Item was a reference type. Mutating the single instance will update the source of the binding.
But it took me so long to realize I should have been using [@]Bindable instead of [@]Binding.
Doing so made the code way cleaner, I was able to remove my sheet(unwrapping:) modifier, and it all works.
But there was no indication I was doing something wrong. Just strange behavior that was hard to understand, and harder to explain.
2/2
=> More informations about this toot | More toots from bens@mastodon.xyz
text/gemini
This content has been proxied by September (ba2dc).