Has anybody found a way to pass a `DispatchQueue` ...
# ios
r
Has anybody found a way to pass a
DispatchQueue
from Swift to a kotlin API?
from what i can see Kotlin exposes dispatch queues as
NSObject *
but a
dispatch_queue_t
is actually supposed to be a
NSObject<OS_dispatch_queue>*
and without this extra protocol adherence, the Swift <-> ObjC interop breaks down
so i don’t see any way to pass a Swift
DispatchQueue
a
Hi there! Try this one:
Copy code
// Swift code:
  let queue = DispatchQueue(label: "queue")
  KotlinClassKt.setQueue(queue: queue)

// KotlinClass.kt :
  fun setQueue(queue: dispatch_queue_t) {
    dispatch_async(queue) {
      println("Hello from queue")
    }
  }