I have this issue with function overloading in Kab...
# multiplatform
h
I have this issue with function overloading in Kable (BLE library for kmp) that it crashes on iOS when calling LogMessage.detail() function. It actually picks the wrong function. These are the functions
Copy code
internal fun LogMessage.detail(data: NSData?, operation: Operation) {
    detail(data?.toByteArray(), operation)
}

internal fun LogMessage.detail(error: NSError?) {
    if (error != null) detail("error", error.toString())
}

internal fun LogMessage.detail(service: CBService? = null) {
    detail("service", service?.UUID?.UUIDString ?: "Unknown UUID")
}

internal fun LogMessage.detail(characteristic: CBCharacteristic) {
    val serviceUuid = characteristic.service
        ?.UUID
        ?.toUuid()
    if (serviceUuid == null) {
        detail("service", "Unknown (null value)")
        return
    }

    detail(serviceUuid, characteristic.UUID.toUuid())
}

internal fun LogMessage.detail(descriptor: CBDescriptor) {
    val characteristic = descriptor.characteristic
    if (characteristic == null) {
        detail("characteristic", "Unknown (null value)")
        return
    }

    val serviceUuid = characteristic.service
        ?.UUID
        ?.toUuid()

    if (serviceUuid == null) {
        detail("service", "Unknown (null value)")
        return
    }

    detail(
        serviceUuid,
        characteristic.UUID.toUuid(),
        descriptor.UUID.toUuid(),
    )
}
and this is the error I got.
Copy code
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CBDescriptor service]: unrecognized selector sent to instance 0x1086a94d0'
*** First throw call stack:
(0x193fff21c 0x191499abc 0x194069614 0x193f13a1c 0x193f13aa0 0x10dddacf0 0x10ddd1a98 0x10ddd4538 0x1bd7cad94 0x1bd7caec4 0x1bd7c7a18 0x1bd786a40 0x1bd78422c 0x1bd784114 0x1034a8584 0x1034c2064 0x1034b091c 0x1034b15d8 0x1034b0758 0x1034b15a4 0x1034bd894 0x1034bceb0 0x21e5f4a0c 0x21e5f4aac)
libc++abi: terminating due to uncaught exception of type NSException
and I also attached the XCode error. Anyone has any idea how to fix it? please let me know if more information is needed.
🧵 1
t
better to ask in #C3SGXARS6
👍 1