Swift: How to add 47 Bool filter to json List

im having trouble setting up 47 facility Bool filters to a json list like the Landmark tutorial json List

its only this first 10 filters that work and the rest don't work when I try them what im I doing wrong..??

var filteredHavneplaner: [Havneplan] {

        userData.havneplaner.filter { havneplan in

            (!filters.showhjertestarterOnly || havneplan.hjertestarter) && (!filters.showpaabroerneOnly || havneplan.paabroerne) && (!filters.showautocamperOnly || havneplan.autocamper) && (!filters.showbeddingOnly || havneplan.bedding) && (!filters.showbenzinOnly || havneplan.benzin) && (!filters.showblaaflagstrandOnly || havneplan.blaaflagstrand) && (!filters.showBaadtilbehorOnly || havneplan.Baadtilbehor) && (!filters.showbaadevaerftOnly || havneplan.baadevaerft) && (!filters.showcykeludlejningOnly || havneplan.cykeludlejning) && (!filters.showdieselOnly || havneplan.diesel) && (!filters.showdykkerklubOnly || havneplan.dykkerklub) && (!filters.showdykkerassistanceOnly || havneplan.dykkerassistance) && (!filters.showelektricitetOnly || havneplan.elektricitet) && (!filters.showelvaerkstedOnly || havneplan.elvaerksted) && (!filters.showfamiliebaderumOnly || havneplan.familiebaderum) && (!filters.showflaskegasOnly || havneplan.flaskegas) && (!filters.showgrillpladsOnly || havneplan.grillplads) && (!filters.showhavnebadbadebroOnly || havneplan.havnebadbadebro) && (!filters.showkrabbebaneOnly || havneplan.krabbebane) && (!filters.showkøbmandsupermarkedOnly || havneplan.købmandsupermarked) && (!filters.showlegepladsOnly || havneplan.legeplads) && (!filters.showmotorassistanceOnly || havneplan.dykkerassistance) && (!filters.showmotorbådsklubOnly || havneplan.motorassistance) && (!filters.shownaturformidlingOnly || havneplan.naturformidling) && (!filters.showsejlmagerOnly || havneplan.sejlmager) && (!filters.showslæbestedOnly || havneplan.slæbested) && (!filters.showsejlklubOnly || havneplan.sejlklub) && (!filters.showshelterOnly || havneplan.shelter) && (!filters.showstrandOnly || havneplan.strand) && (!filters.showsupklubOnly || havneplan.supklub) && (!filters.showtoiletbadOnly || havneplan.toiletbad) && (!filters.showtomningaftankOnly || havneplan.tomningaftank) && (!filters.showtorretumblerOnly || havneplan.torretumbler) && (!filters.showudlejningshytterOnly || havneplan.udlejningshytter) && (!filters.showvandlegepladsOnly || havneplan.vandlegeplads) && (!filters.showvandpolobaneOnly || havneplan.vandpolobane) && (!filters.showvinterbadereOnly || havneplan.vinterbadere) && (!filters.showvaskemaskineOnly || havneplan.vaskemaskine) && (!filters.showoffentligtransportOnly || havneplan.offentligtransport) && (!filters.showwifiOnly || havneplan.wifi) && (!filters.showvaerftOnly || havneplan.vaerft) && (!filters.showrestaurantOnly || havneplan.restaurant) && (!filters.showsejlerstueOnly || havneplan.sejlerstue) && (!filters.showbadOnly || havneplan.bad) && (!filters.showfrihavnOnly || havneplan.frihavn) && (!filters.showsikkerhavnOnly || havneplan.sikkerhavn) && (!filters.showonlinehavnepengeOnly || havneplan.onlinehavnepenge) && (!showFavoritesOnly || havneplan.isFavorite) && (filters.minlaengde < havneplan.laengde) && (filters.minbredde < havneplan.bredde) && (filters.mindybgang < havneplan.dybgang) && (filter == .all || filter.rawValue == havneplan.category.rawValue) && (filtertwo == .all || filtertwo.rawValue == havneplan.typehavn.rawValue)

        }

        

    }
var title: String {

        let title = filter == .all ? "Havneplaner" : filter.rawValue

        _ = filtertwo == .all ? "Havneplaner" : filtertwo.rawValue

        return showFavoritesOnly ? "Favoriter \(title)" : title

    }

    var index: Int? {

        userData.havneplaner.firstIndex(where: { $0.id == selectedHavnePlan?.id })

    }
List(selection: $selectedHavnePlan) {

            ForEach(filteredHavneplaner.filter({ self.searchTerm.isEmpty ? true : $0.name.localizedCaseInsensitiveContains(self.searchTerm) })){ havneplan in

                        if !self.userData.showFavoritesOnly || havneplan.isFavorite,!self.userData.showhjertestarterOnly || havneplan.hjertestarter,!self.userData.showpaabroerneOnly || havneplan.paabroerne,!self.userData.showautocamperOnly || havneplan.autocamper,!self.userData.showbeddingOnly || havneplan.bedding,!self.userData.showbenzinOnly || havneplan.benzin,!self.userData.showblaaflagstrandOnly || havneplan.blaaflagstrand,!self.userData.showBaadtilbehorOnly || havneplan.Baadtilbehor,!self.userData.showbaadevaerftOnly || havneplan.baadevaerft,!self.userData.showcykeludlejningOnly || havneplan.cykeludlejning,!self.userData.showdieselOnly || havneplan.diesel,!self.userData.showdykkerklubOnly || havneplan.dykkerklub,!self.userData.showdykkerassistanceOnly || havneplan.dykkerassistance,!self.userData.showelektricitetOnly || havneplan.elektricitet,!self.userData.showelvaerkstedOnly || havneplan.elvaerksted,!self.userData.showfamiliebaderumOnly || havneplan.familiebaderum,!self.userData.showflaskegasOnly || havneplan.flaskegas,!self.userData.showgrillpladsOnly || havneplan.grillplads,!self.userData.showhavnebadbadebroOnly || havneplan.havnebadbadebro,!self.userData.showkøbmandsupermarkedOnly || havneplan.købmandsupermarked,!self.userData.showlegepladsOnly || havneplan.legeplads,!self.userData.showmotorassistanceOnly || havneplan.motorassistance,!self.userData.showmotorbådsklubOnly || havneplan.motorbådsklub,!self.userData.shownaturformidlingOnly || havneplan.naturformidling,!self.userData.showslæbestedOnly || havneplan.slæbested,!self.userData.showsejlklubOnly || havneplan.sejlklub,!self.userData.showshelterOnly || havneplan.shelter,!self.userData.showstrandOnly || havneplan.strand,!self.userData.showsupklubOnly || havneplan.supklub,!self.userData.showtoiletbadOnly || havneplan.toiletbad,!self.userData.showtomningaftankOnly || havneplan.tomningaftank,!self.userData.showtorretumblerOnly || havneplan.torretumbler,!self.userData.showudlejningshytterOnly || havneplan.udlejningshytter,!self.userData.showvandlegepladsOnly || havneplan.vandlegeplads,!self.userData.showvandpolobaneOnly || havneplan.vandpolobane,!self.userData.showvinterbadereOnly || havneplan.vinterbadere,!self.userData.showvaskemaskineOnly || havneplan.vaskemaskine,!self.userData.showoffentligtransportOnly || havneplan.offentligtransport,!self.userData.showwifiOnly || havneplan.wifi,!self.userData.showvaerftOnly || havneplan.vaerft,!self.userData.showrestaurantOnly || havneplan.restaurant,!self.userData.showsejlerstueOnly || havneplan.sejlerstue,!self.userData.showbadOnly || havneplan.bad,!self.userData.showfrihavnOnly || havneplan.frihavn,!self.userData.showonlinehavnepengeOnly || havneplan.onlinehavnepenge {

                    NavigationLink(destination: HavnePlanDetail(havneplan: havneplan) .environmentObject(self.userData) ) {

                        HavnePlanRow(havneplan: havneplan)

                    }

                }

            }

        }

How did you get on with this question on Stack Overflow?

I don't know how to solve your issue, but perhaps this clue will help...

In SwiftUI, a ViewBuilder is limited to a maximum of 10 Views.
It looks like there may be a similar limit to filters?

I found your code a bit confusing (json doesn't seem to have any relevance), but I suspect there may be a more elegant solution.

Would you like to post a bit more about what you are trying to achieve, and how (and why)?

...

I did not delete the post

Have you considered rewriting it as a method that tests each Bool individually, and returns the overall Bool result?
Perhaps something like...

func include() -> Bool {
    if !filters.showhjertestarterOnly || havneplan.hjertestarter {
        return true
    }
    if !filters.showpaabroerneOnly || havneplan.paabroerne {
        return true
    }
    /// And so on, through your 47 Bools...
    return false
}

10 is a frequent limit in SwiftUI.

Can't you split the filtering by groups of 10 filters ?

Swift: How to add 47 Bool filter to json List
 
 
Q