I’ve a SwiftUI view which is a sheet that presents the customers with alternative ways of choosing filters:
struct FilterSheet: View {
@Binding var choices : FilterOptions
...
The chosen filters are saved and handed to a parent-view utilizing the FilterOptions
struct:
struct FilterOptions : Equatable{
var searchText = ""
var nations = Set<String>()
var reverse = false;
...
One of many methods of filtering is by deciding on from a listing of nations, which is included within the FilterSheet
by means of a navigation hyperlink to a UIView with a SwiftUI checklist.
NavigationLink(vacation spot: CountryFilter(nations: SiteData.shared.allCountries, choice: $choices.nations)){
Which is finished through the use of a quite simple UIView:
struct CountryFilter: View {
var nations : [String]
@Binding var choice : Set<String>
var physique: some View {
VStack {
Checklist(nations, id: .self, choice: $choice) { nation in
Textual content(nation)
}
.setting(.editMode, .fixed(.energetic))
Textual content("(choice.depend) nations chosen")
}
}
}
Nevertheless, for some cause, the choice within the checklist (in edit mode) doesn’t replace the view in any respect, nor does it propagate to the father or mother FilterSheet view. After I use a easy @State var for the choice, it does work domestically. What’s the cause this doesn’t work?