Post marked as solved
Click to stop watching this thread.
You have stopped watching this post. Click to start watching again.
contentPostList.repliessolved.tooltip
Replied In
SwiftUI List reload causes crash
I encountered the same error and stumbled onto this thread. Its helped me fix the issue, using another solution - in case anyone is interested.
My List displays search results based on two search parameters, and the results were clubbed into Sections, where each Section consolidated the results for one parameter. The List displays fine when the search is first run. But changing the parameters or the interval caused the Sections to change their order leading to the same crash as described on this thread.
I solved it by assigning an ID value to the List. And then changed this ID each time the user taps the search button to generate a new search. eg
@State var listID = 1
List {
ForEach(parameter1){
Section {
//all the rows matching this parameter
}
}
}
.id(listID) //this solved the issue
Button(action:{
self.fetchResults
self.listID += 1 //increment the ID, thereby causing the List to reset its state and prevents the crash
}, label: {
Text("Search")
}
)
Hope it helps anyone who faces the same crash error!