Shubham Pathak2000
02/20/2025, 8:46 AMobject
in iOS app. Everytime i'm using a method of a singleton class (tried both object as well as normal way of creating singleton), a new instance of the class is getting created, defeating the whole singleton purpose. I'm currently on Kotlin 2.0.21 and SKIE 0.9.5. Has anyone faced something similar?yousefa2
02/20/2025, 9:52 AM.shared
property that should get you the singletonShubham Pathak2000
02/20/2025, 9:54 AMyousefa2
02/20/2025, 9:55 AMShubham Pathak2000
02/20/2025, 11:55 AMinternal object ClientHandler {
private val clientMap = hashMapOf<String, Client>()
private var defaultClient: Client? = null
fun addClient(clientTag: String, client: Client, isDefault: Boolean = false) {
clientMap[clientTag] = client
if (isDefault) {
defaultClient = client
}
}
fun getClient(clientTag: String): Client? {
return clientMap[clientTag]
}
fun getDefaultClient(): Client? {
return defaultClient ?: clientMap.values.firstOrNull()
}
}
Shubham Pathak2000
02/20/2025, 11:55 AMShubham Pathak2000
02/20/2025, 11:56 AMyousefa2
02/20/2025, 1:53 PMShubham Pathak2000
02/20/2025, 2:23 PM