Thank you partially helpful in getting past the errors so syntax is right but when I enter my search string (when it's 3 or more characters) and it kicks in using the predicate the result is no matches even though I know for certain that the search fields are present. If I don't run the predicate I get my full list with search entries (see screen shot) but if I type in a known string that's in the search string so should return a true (and maybe it does) I get nothing in the resulting sectionsDB. I've included some code here to show how I enter the predicate and pass it. Must be something down stream in "FilteredList" I need to do?
struct FilteredList: View {
@EnvironmentObject var userSettings: UserSettings
@Environment(\.modelContext) private var context
@Query() var sectionsSD: [SectionsSD]
private var isExpanded: Bool
var body: some View {
List(sectionsSD) { result in
Section(result.section) {
ForEach(result.toArticles!) { article in
NavigationLink(destination: ArticleView(title: article.title, summary: article.summary, content: article.body)) {
VStack(alignment: .leading) {
Text(article.title)
.font(.custom("Helvetica", size: 16))
if isExpanded {
Text(article.summary)
.font(.custom("Helvetica", size: 12))
.foregroundColor(Color(UIColor.systemGray))
Text(article.search)
}
}
}
/// Hide the row separator
.listRowSeparator(.hidden)
}
}
}
}
init(filter: String, isExpanded: Bool) {
if filter.count >= 3 {
let searchPredicate = #Predicate<SectionsSD> {
$0.toArticles.flatMap {
$0.contains { $0.search.contains(filter) }
} == true
}
_sectionsSD = Query(filter: searchPredicate)
}
self.isExpanded = isExpanded
}
}