Using cinterop to bring in an objc framework and o...
# kotlin-native
d
Using cinterop to bring in an objc framework and one of the functions it generated is
fun niceMockForClass(aClass: kotlinx.cinterop.ObjCClass?): kotlin.Any?
. How do we get an instance of
ObjCClass
from an existing object or from a class type?
s
How do we get an instance of
ObjCClass
from an existing object
Just like for any other Objective-C object: by calling
class
method on it. In Kotlin you have to escape it with backticks:
Copy code
theObject.`class`()
or from a class type?
If
Foo
is an Objective-C class, then it has companion object which is
ObjCClass
, so
Foo
can be passed for
ObjCClass
parameter.
d
awesome. thx