How can I access a Kotlin `object` from Swift?
# multiplatform
l
How can I access a Kotlin
object
from Swift?
v
You need to "fake instantiate it" like so:
ObjectFromKotlin()
l
Great, thank you!
v
Glad to be able to help!
❤️ 1
a
There should be a
.shared
static property
thank you color 1
l
Oh yes, I see it.
v
@Alexander Zhirkevich Thanks for chipping in! Does it mean that what I suggested creates a new instance every time then?
a
Definitely
v
Understood, I'll have a talk with the iOS team then haha. Thank you @Alexander Zhirkevich and sorry @Lukasz Kalnik for misleading you, I just gave you the approach I was using.
❤️ 1
l
No worries, you meant well and I would've caught it sooner or later, that my ViewModel is a new instance every time 😉
kodee loving 1
s
Does it mean that what I suggested creates a new instance every time then?
No, it still going to be a singleton, but access through
shared/companion
class properties is preferable as it is more explicit. See documentation here (including links to interopedia)
thank you color 3