I have a list (sourced from Core Data) where each row is tappable and it opens a sheet. I’m passing an Observable Object from the list to the view loaded within the Sheet/Modal. I struggled with this code when I wrote it during the early/buggy days of SwiftUI last June (2019) and eventually ended up storing an ID in the row's View, then doing a lookup at time of tap. This worked great in iOS13 (and continues to do so even in Xcode 12) and resolved issues I had been experiencing with sheets opening the first time but never again (or not being dismissible). With that said, this doesn't sound like the right way to go, partially confirmed by this not working in iOS 14. I can't seem to find a good example anywhere of how one is supposed to do this.
List {
ForEach (locationStore.locations) { location in
LocationRow(location: location, showLocationDetailsModal: self.$showLocationDetailsModal, locationIDToShowDetails: self.$locationIDToShowDetails)
}
}
.sheet(isPresented: self.$showLocationDetailsModal,
content: {
LocationDetailView(location: self.locationStore.locations.first(where: {$0.id == self.locationIDToShowDetails})!)
.environmentObject(self.locationStore)
.environmentObject(self.applicationManager)
})
Post
Replies
Boosts
Views
Activity
I used to be able to "right click" on the play button for a preview, but in Beta 1 and 2 of Xcode 13 that isn't working (neither is control clicking). Any ideas how to debug a preview short of running app in the simulator?