I'm trying to implement `PTChannelManagerDelegateP...
# kotlin-native
t
I'm trying to implement
PTChannelManagerDelegateProtocol
in iosMain and I'm getting
"Conflicting overloads"
exceptions. The confusing part to me is that the methods all have unique parameter names. Here is an example of two methods:
Copy code
public open fun channelManager(channelManager: PTChannelManager, didActivateAudioSession: AVAudioSession): 
public open fun channelManager(channelManager: PTChannelManager, didDeactivateAudioSession: AVAudioSession):
How do I resolve these errors?
l
You can use the name of the parameter to distinguish https://kotlinlang.org/docs/native-objc-interop.html#method-names-translation
t
It's not compiling though. That is the issue.
Screenshot 2024-03-21 at 6.00.19 PM.png
Copy code
class PushToTalkManager(
): NSObject(), PTChannelManagerDelegateProtocol, PTChannelRestorationDelegateProtocol {
}
This is how I'm trying to use it.
l
I see. You're overriding, not calling. I remember running into this before and fixing it, but don't remember off hand how I resolved this.
👍 1
The worst-case solution I can think of is to use a cinterop def file to create an abstract class in Obj-C that implements this, and provides methods with different names, then extend that in Kotlin, but that's obviously not a good experience.
Can you just suppress the error? I think some of these K/N oddities are suppressable.
t
Android Studio isn't suggesting any way to suppress. I'll dig through the docs some more.
d
Parameter names are not important in the signature of a method. The signature consist only of the function name and the ordered parameter types. So in your case, both functions have the same name and the same ordered parameter types. So having different parameter names does not help
l
@Suppress("CONFLICTING_OVERLOADS")
t
That suppresses the error. 🙂
l
The methods come from an Obj-C interface, where unfortunately, the name of a parameter is part of the method's signature.
t
I'll clean this up and hopefully it will build. Thanks for the help!
d
@Landry Norris ah, ok.
l
I could have sworn there was an annotation that told the compiler about this condition, but I may just be thinking of the suppress.
👍 1