Is there something I can do to make ```fun section...
# multiplatform
n
Is there something I can do to make
Copy code
fun sectionForIndex(index: Int): Section?
not compile to
Int32
in my objective-c framework?
I may just not know enough Swift, but it's annoying not being able to pass a Swift
Int
to this function.
s
Change it to:
Copy code
fun sectionForIndex(index: Long): Section?
n
Is this intentional design by Jetbrains?
s
Kotlin Ints are 32-bit whereas Swift integers are 64-bit on 64-bit platforms.
n
doh, okay. thank you
s
Beware of that if you plan on targeting older iOS devices/versions as it will cause some pain. For the most part 32-bit iOS stuff has been dead for long enough that it isn’t hard to justify not supporting it.
n
Good catch!
Are there any Kotlin/Multiplatform "gotcha" pages we could add this to?
s
I’m not aware of any.
k
Would be a big page. I kid.
n
Gotcha #1: using experimental, unreleased frameworks
k
What, mutliplatform? Experimental, maybe, but not unreleased.
Also, I think technically the multiplatform is experimental, but native is beta, but I may be misremembering that.
n
unreleased was probably too strong of a joke, but that's interesting about native.
k
The platform is “stable” in the sense that the runtime is OK. There’s definitely a few surprises, though. All improving over time.
n
@Sam Long semi-works, but now it requires an
Int64
wrapper. Was this what you expected?
b
There’s some info about primitive numbers interop between Kotlin <-> iOS (https://kotlinlang.org/docs/reference/native/objc_interop.html#nsnumber). Looks like you can pass in an
NSNumber
object instead.
s
It isn’t quite the way I remember it working no.
k
If the type you’re expecting is an Int or Long, you can’t pass in NSNumber. That’s for a different situation (I assume. Too late/tired to try to make an example). I’m pretty sure you do need to explicitly cast to Int64. Not ideal, but you know. It works. I’ve been mostly passing objects in/out, so I’m a little rusty on how primitives work.
n
@kpgalligan thanks for the sanity check. If it's the way it is, that's fine, it does work after all, but it's good to hear that's apparently the common solution.