I want to override two methods at the same time th...
# compose-ios
c
I want to override two methods at the same time that come from iOS so that I can read and write nfc tags. In my kotlin code I try to write
Copy code
override fun readerSession(session: NFCNDEFReaderSession, didDetectNDEFs messages: List<*>) {
        // Read nfc tags
    }

    override fun readerSession(session: NFCNDEFReaderSession, didDetectTags: List<*>) {
    // write nfc tags
    }
but I'm 'not allowed (seemingly because the method signatures are the same. Any way around that? It swift it seems like you can use declare both methods in the same file
1
If it helps, these are the two method calls when I drill into them from my kmp code
Copy code
@kotlin.commonizer.ObjCCallable @kotlinx.cinterop.ObjCMethod public abstract expect fun readerSession(session: platform.CoreNFC.NFCNDEFReaderSession, didDetectNDEFs: kotlin.collections.List<*>): kotlin.Unit

    @kotlin.commonizer.ObjCCallable @kotlinx.cinterop.ObjCMethod public open expect fun readerSession(session: platform.CoreNFC.NFCNDEFReaderSession, didDetectTags: kotlin.collections.List<*>): kotlin.Unit { /* compiled code */ }
Oooh: TIL about @ObjCSignatureOverride
f
still an issue?
c
I used @ObjCSignatureOverride, and while that made the compilation issues go away. It seems like I can't write a single nfcManager that can mode read and write. So I basically am in the process of writing a NfcWriterManager and NfcReaderManager and hopefully that works
f
I’m testing the implementation of
NFCNDEFReaderSessionDelegateProtocol
and it’s really bad, I’m will report it
@Colton Idle Issue here 😄
c
Nice! Thank you! I'm really not sure if it's my lack of kmp knowledge, or ios knowledge thats giving me the issue. In any case... I do seem to be able to read and write successfully from both android and ios. so thats kinda cool!
f
The issue was made months ago, sometimes it's good to look inside the youtrack, it was clearly an issue from Kotlin CIntrop.
c
Very interesting! Thanks for the tip!
f
Learning KMP is a long journey 😄
☝️ 1
c
Hey @François i'm circling back to this and was just wondering if you ever implemented reading AND writing via nfc on iOS. I think I maybe found the culprit of my issue. I am currently using NFCNDEFReaderSessionDelegateProtocol, but it looks like I should maybe also be using NFCTagReaderSessionDelegateProtocol. got any tips around when to use one over the other?
f
Hi, I did on iOS and Android, the setup of both platform are really different
The usage of the correct Protocol of what do want to read/write, which hardware
c
I have reading/writing working on android. on ios it mostly sorta works. but for some reason... with NFCNDEFReaderSessionDelegateProtocol I can't grab the identifier of the tag. Which I need. so hence i was looking at NFCNDEFReaderSessionDelegateProtocol
f
Did you try the another protocol ?
Nfctagreader?
The NFC reader of ios is kind of more limited than Android, so take care of what you want to do with it.
c
I have not tried NfcTagReader because from what I was looking at doing I thought Ndef was the way to go. but i guess ill try the more bare bones tag reader and see where that leads me.