https://kotlinlang.org logo
g

gpaligot

02/07/2022, 1:44 PM
Hi here, I have a strange behavior with a model shared with an Android and iOS application. My model is:
Copy code
data class AgendaUi(val talks: Map<String, List<TalkItemUi>>)
And I have a fake data in Kotlin too:
Copy code
val fakeAgendaUi = AgendaUi(
    talks = mapOf(
        "10:00" to arrayListOf(fakeTalkItem, fakeTalkItem),
        "11:00" to arrayListOf(fakeTalkItem, fakeTalkItem),
        "12:00" to arrayListOf(fakeTalkItem, fakeTalkItem),
    ),
)
The usage of this fake data work fine on Android but when I use this fake data instance on iOS, I receive a Dictionary with the good key and a list of two
NSNull
elements. But if I create the fake data in Swift, everything work fine:
Copy code
let agenda = AgendaUi(
    talks: [
        "10:00": [TalkItemUiKt.fakeTalkItem, TalkItemUiKt.fakeTalkItem],
        "11:00": [TalkItemUiKt.fakeTalkItem, TalkItemUiKt.fakeTalkItem],
        "12:00": [TalkItemUiKt.fakeTalkItem, TalkItemUiKt.fakeTalkItem],
        "13:00": [TalkItemUiKt.fakeTalkItem, TalkItemUiKt.fakeTalkItem],
    ]
)
Somebody know why? A bug in interoperability maybe?
m

mkrussel

02/07/2022, 2:01 PM
It's that the initialization in Kotlin native between
fakeAgendaUi
and
fakeTalkItem
is not well defined. I think there is a fix for this coming soon, but I cannot remember where I saw details about it.
g

gpaligot

02/07/2022, 7:54 PM
Thanks @mkrussel for the link to the issue!
3 Views