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

Zhan Huang

10/23/2019, 5:57 PM
I'm trying to create a shared interface for iOS and Android in kotlin multiplatform, and have this function that takes in a url. Is there a way I can make the iOS function take NSURL, but the android one take java.net.Url? Or should I just stick to String?
k

Kris Wong

10/23/2019, 5:58 PM
you can use an expect class with typealiases, but you may need a wrapper to unify the API, dependening on how you plan to use it
☝️ 5
z

Zhan Huang

10/23/2019, 6:03 PM
that's genius. I'll have to try it out. thanks!
Just realized it's a part of the kotlin multiplatform documentation: https://kotlinlang.org/docs/reference/platform-specific-declarations.html (at the bottom). I really need to find some time and just read the whole thing.