Follow

Okay one for the crowd: Do we have a definitive answer whether a List's selection binding should be Identifiable or not?

Apple seem to play fast and loose with this. Some of their example projects (Food Truck) don't conform to Identifiable, and the Swift header for List only has Hashable as the requirement. Meanwhile the docs say a List's selection should conform to Identifiable.

So what is the truth? What do you do in your apps?

· Edited · · Ivory for Mac · 2 · 1 · 0

@phill But list supports elements that are not identifiable (by supplying an id keypath). How would that work if selection required Identifiable?

@kaybutter well there does appear to be a separate overload for Identifiable elements, and the docs seem to suggest you should be using that. But you're right, you can use none Identifiable elements and it’ll just use the hash. I'm just curious if it has any practical implications, and if it could explain some of my List weirdness.

@phill Some of the SwiftUI design choices made a lot more sense to me the first time I used it with CoreData. All of my model objects where automatically observable, hashable, and identifiable, and many things clicked for me.

Some things still haven’t clicked though, haha

@brandonhorst Aha, the first version of Big Mail used CoreData: never again 🥲

I understand how things piece together, but in practice the API’s never seem to work the way I expect. There's either obscure overloads, hidden environment values, or it doesn't behave the way the docs say it should. Nor does it help that Apple’s own examples are either inconsistent or incomplete.

Sign in to participate in the conversation
The Not So Big Company

The home of The Not So Big Company on Mastodon.