List selection binding on iOS

I noticed that on iOS when I tap an already selected List row it calls the selection binding setter again. This is suprising to me because the selection value hasn't changed and results in duplicating unnecessary work to transform the data. Is this behaviour normal or should I report it as a bug?

I noticed it when using custom Binding for the selection, i.e. where I implement the get and set closures myself.

Thanks!

Answered by Frameworks Engineer in 892332022

You don't have to transform the data if you know the selected item is being selected again. SwiftUI must support all use cases, and some use cases demand that the binding gets called over and over again!

You don't have to transform the data if you know the selected item is being selected again. SwiftUI must support all use cases, and some use cases demand that the binding gets called over and over again!

List selection binding on iOS
 
 
Q