Hi, a quick question. Does anyone know the best pr...
# getting-started
h
Hi, a quick question. Does anyone know the best practice of Singleton in Kotlin multiplatform? I have something like
Copy code
object MyClass {
   var myValue:xxx
}
defined in the kotlin module. I’m trying to access it in iOS with something like`MyClass().myValue`, but my app crashes immediately with error: Thread 1: EXC_BAD_ACCESS (code=1, address=0xa8). It also crashes with the same message if I use
MyClass.shared.myValue
k
What about just
MyClass.myValue
h
the build will fail: “Instance member ‘myValue’ cannot be used on type ‘MyClass’;…”