In this video: https://developer.apple.com/videos/play/wwdc2019/103/, the following snippet of code is shown at around 15:30:
...
ForEach(ContentSizeCategory.common.identified(by: \.self))
...
What does it do? Where does self
points to? The current object (TraitCell_Preview
)? It doesn't even compile in my computer since common
isn't a member in ContentSizeCategory
. I thought I had seen it before in a SwiftUI
talk (\.self
) . Keypath
's aren't my best thing in Swift though.
I understand ForEach
's elements needs to be Identifiable
. self
(a.k.a. TraitCell_Preview
right?) does only conform to PreviewProvider
so not Identifiable
(if the private _PreviewProvider
protocol from which PreviewProvider
conforms to doesn't conform to Identifiable
, not sure about that since I can not see the code).
What is \.self
in the snippet of code and where does it points to?