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

Charles Prado

06/05/2021, 5:19 PM
There's any way to make iOS headers understand default properties set on the Kotlin side? In Kotlin I have this class:
Copy code
@Serializable
@Parcelize
data class SomeClass(
    val id: String = "",
    val name: String = "",
    val mandatory1: String,
    val mandatory2: String,
)
On the iOS side, what I want is:
Copy code
// SomeiOSClass.swift 
let instance = SomeClass(mandatory1: "foo", mandatory2: "bar")
instead of :
Copy code
// SomeiOSClass.swift 
let instance = SomeClass(id: "someId", name: "someName", mandatory1: "foo", mandatory2: "bar")
Is it possible to not have to set those properties that already have a default value defined on Kotlin's side?
e

ephemient

06/05/2021, 7:08 PM
no, because K/N interop is at the Objective-C level, which doesn't support default args
c

Charles Prado

06/05/2021, 7:12 PM
I imagined that could be the reason 😅
e

ephemient

06/05/2021, 7:14 PM
if there were something equivalent to
@JvmOverloads
that might help, but there isn't, https://youtrack.jetbrains.com/issue/KT-38685
x

xxfast

06/06/2021, 2:48 AM
same goes for the
copy()
function i guess
3 Views