As title says, the next code crashes when segmented picker is modified by tapping on it. The next is the code for the view that can be utilized to copy the issue.
import SwiftUI
import SwiftData
struct ErasemeView: View {
@Question(filter: #Predicate<Counter> { !$0.isDeleted }) personal var counters: [Counter]
// @Question personal var counters: [Counter]
@State var allOrToday: Int = 0
var physique: some View {
NavigationStack {
VStack {
Picker("", choice: $allOrToday) {
Textual content("All").tag(0)
Textual content("As we speak").tag(1)
}
.pickerStyle(.segmented)
Listing {
ForEach(counters) { counter in
Textual content(counter.title)
}
}
}
}
}
}
This system works after I take away the predicate and use the fundamental Question
.
@Question personal var counters: [Counter]
The allOrToday
variable shouldn’t be impacting the view’s show. Any thought how this may be fastened?
Edit: Truly, it won’t be a crash however UI retains updating. After I put Self._printChanges() in physique(), I see messages like this repeatedly printing:
..
ErasemeView: @dependencies modified.
()
ErasemeView: @dependencies modified.
()
...