https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
o

Olenyov Kirill

01/29/2020, 9:46 AM
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

Artyom Degtyarev [JB]

01/30/2020, 12:37 PM
Hello! What’s wrong with it? You should be available to work with both these types from the Objective-C side, AFAIK.
o

Olenyov Kirill

01/30/2020, 12:50 PM
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

Artyom Degtyarev [JB]

01/30/2020, 1:20 PM
No, this behaviour is expected.
o

Olenyov Kirill

01/30/2020, 1:23 PM
Ok, thanks. Can I read somewhere about this behavior? I would like more about this..
a

Artyom Degtyarev [JB]

01/30/2020, 3:08 PM
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

Olenyov Kirill

01/30/2020, 3:12 PM
Thanks! Now it’s clear!