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

Olenyov Kirill

01/18/2020, 10:51 AM
Question regarding obj-c <-> swift interop. In K/N I created two methods:
Copy code
fun test1(): List<Channel> {        
}

fun test2(): MWResponse<List<Channel>> {
}
Where Channel and MWResponse are just data and sealed classes. In generated obj-c header I see:
Copy code
- (NSArray<CommonChannel *> *)test1 attribute((swift_name("test1()")));
- (CommonMWResponse<NSArray<CommonChannel *> *> *)test2 attribute((swift_name("test2()")));
Looks good. “List<Channel>” was converted to obj-c “NSArray<Channel>” But in Swift these methods shown as:
Copy code
[Channel] test1()
MWResponse<NSArray> test2()
So two questions: 1) Why it has two different “array” types: [] and NSArray? 2) Where is generic type for test2() method? It should be NSArray<Channel> i think.. Is it a problem in objc-swift interop or mpp problem?
@akapanina Could anyone from JB see my question about generics in mpp? I’m not sure that is K/N/mpp issue. Or maybe it is and I need to create an issue for mpp?
👀 1
a

Artyom Degtyarev [JB]

01/22/2020, 2:34 PM
Hello! Sorry for such a long silence. On a first sight, I agree that the second thing is incorrect a little bit. We are going to investigate it for some time, so please stay tuned for updates.
o

Olenyov Kirill

01/22/2020, 2:35 PM
Ok, thanks!
s

svyatoslav.scherbina

01/22/2020, 2:38 PM
This is generally how Swift -> Objective-C interoperability works. Likely has nothing to do with K/N directly.
n

nrobi

01/29/2020, 9:33 AM
Any hope that this improves in the future? 😄
3 Views