Hi, I hava another issue now with generics and obj...
# multiplatform
o
Hi, I hava another issue now with generics and obj-c. In kotlin I have a simple class with Int types:
Copy code
data class MyTestDataClass(val ppp: Int, val ttt: List<Int>)
But in obj-c it looks like: CommonMyTestDataClass : KotlinBase - (instancetype)initWithPpp:(int32_t)ppp ttt:(NSArray<CommonInt *> *)ttt So different types: int32_t and CommonInt WTF?
a
Hello! What’s wrong with it? You should be available to work with both these types from the Objective-C side, AFAIK.
o
Actually, I don’t know:) My iOS team said that these types are different and may be it’s a bug Kotlin<->ObjC mapping..
a
No, this behaviour is expected.
o
Ok, thanks. Can I read somewhere about this behavior? I would like more about this..
a
As you can see in this table(https://kotlinlang.org/docs/reference/native/objc_interop.html#mappings), Kotlin primitive types are mapped into either primitive types or
NSNumber
. Also, there is a note on boxes mapping, explaining your case. As a
List
in your example should be exported
NSArray
, it has to use
NSNumber
subclass. In Objective-C, one cannot make NSArray of primitive types.
o
Thanks! Now it’s clear!