https://kotlinlang.org logo
#ios
Title
# ios
a

Anonymike

03/16/2023, 4:36 PM
I realized there is an ios specific channel and thought this question may be better suited here. I appreciate any help you can offer.
k

Kevin S

03/16/2023, 5:01 PM
I have not seen this before but it’s possible that
id
is a special name. In objective-C
id
is a pointer type, so maybe that is the issue. Can you try renaming it slightly and seeing if it works? Maybe try
_id
or
identifier
. If you are getting this from somewhere you can also use @SerializedName to cover the name change
a

Anonymike

03/16/2023, 5:22 PM
Thanks so much for your response! So far I tried making a quick computed property like so:
val itemId get() = id
but that fails as well. I'm trying to republish the API with the property changed to test this more thoroughly, but whats really odd is we have other properties called id as well in the exact same style and we even see id in many examples.
Ok, yesterday I was able to test republishing the api with only that class having its
id
changed from id to
itemId
. It worked and the only difference with that class turns out to be that it implements an interface that defines the
id
property. My guess right now is that you are correct and the Objective-C
id
issue is causing the problem, but only when
id
is part of an interface, not when it is part of a class. This project has multiple other data classes, all with
id
properties that work fine. Thank you for your input @Kevin S. If I can, I'll try to create a reproducer for the Kotlin team if it is something they can handle. I'm assuming they did something to handle this with non-interface classes, but I don't know Objective-C well enough to say offhand. I do know we also ran into a similar issue with a property named
description
on our first project haha.
8 Views