Hello folks, I have a question regarding `iosMain`...
# multiplatform
c
Hello folks, I have a question regarding
iosMain
because it says we can use ios spesific API inside it. Can we use
DispatchQueue
inside
iosMain
? (If you don't know,
DispatchQueue
is the common ios API that we use for background processing stuff)
Somehow I can't find a way to import and use it in
iosMain
j
Yes, you can. But note, the API is not the Swift API. The type is
dispatch_queue_t
in Objective-C.
For example:
Copy code
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT.convert(), 0.convert())) {
    // some background work
}
c
Nice, thanks for the example @Jeff Lockhart. Btw I'm curious, what should we do if we want to do API call inside
dispatch_async(){}
?, should we launch a coroutine first ?
a
i wouldnt mix both dispatch queue and coroutines, it sounds like it could get very tricky to debug.
why wouldnt you just use coroutines in KMP scope
☝🏼 1