Hi, resourceId is removed?
# moko
a
Hi, resourceId is removed?
a
no. why you think it?
a
MR.strings.app_name.resourceId is not accessible
a
resourceId accessible for android target
a
But in docs, we can access
a
okay
any way to get Stirng via Id in commonMain?
a
no way. id is different things on different platforms
a
Any workaround ?
a
for what? what is resourceId in your case? what is it in common main?
a
Let’s say if I want to get string via string id in strings.xml in commonMain I’m using this approach on Android side. First resource id from strings class then string via id.
Copy code
fun getResId(resName: String, c: Class<*>): Int {
    return try {
        val idField: Field = c.getDeclaredField(resName)
        idField.getInt(idField)
    } catch (e: Exception) {
        e.printStackTrace()
        -1
    }
}
a
you can try to achive same with expect/actual function
in ios id - string, in android id - int. if you will use string as id you can try to read on android id by your code and on ios by just pass string as id