SwiftUI - If inside ForEach loop

前端 未结 3 768
猫巷女王i
猫巷女王i 2021-01-18 15:30

I am building a List based on my elements in an array I fetched before.

I am fetching all the entities.. when the user makes a search in the search bar, I want to fi

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-18 16:09

    filter your data BEFORE passing it to ForEach constuctor.

    ForEach(self.documentItems.filter {self.checkSearchString(document: $0)}, id: \.self) { document in
        HStack(spacing: 0)
            {
                ListRow(document: document).tag(document)
            }
    }
    

提交回复
热议问题