I was having trouble accessing the companion objec...
# kotlin-native
s
I was having trouble accessing the companion object instance from Swift code. We could access it, but had to create an instance of the companion object to do so, i.e.
<Kotlin Class>.Companion().<companion function>()
. Did we overlook something, or is this a known limitation?
k
You have to do the same with regular top level objects. I assume under the hood the
Companion()
call returns a single instance if called multiple times, but will defer to others
✔️ 1
s
So
Companion()
is exposed as a function, not a class?
s
No. It is constructing an instance but the way ObjC memory allocation/initialization works, it is effectively a constructor that always returns the same instance.
s
Cool, thanks
k
Did a little test. Can confirm single instance
s
cool thanks!