Is it possible to write a data class in a Kotlin Multiplatform library that, when built for macOS, conforms to Equatable (or better yet, Identifiable) out of the box?
👀 3
s
Sam
10/01/2020, 2:34 AM
Those are Swift only protocols and cannot be implemented in Kotlin or ObjectiveC.
l
louiscad
10/01/2020, 10:16 AM
I believe you can write a Swift extension for Kotlin's
Any?
and delegate to
equals
. Does it work for you @Julio Zynger?
😅 1
a
Arkadii Ivanov
10/01/2020, 2:41 PM
AFAIK for
Identifiable
you just need a field named
id
in your data class. Then you can simply add
Identifiable
Swift extension to the Kotlin data class.
Copy code
data class Data(val id: String)
extension Data : Identifiable {
}