Thread
#multiplatform
    t

    Tony

    2 years ago
    in kotlin native, can we use NSURL for the network stack? (trying to find ktor alternative)
    t

    Tony

    2 years ago
    Thanks Nikolay!
    s

    Sam

    2 years ago
    One gotcha to be aware of is that NSURLSession will call your call back on a background thread. It is up to you to switch over to the main thread (GCD or other mechanism).
    t

    Tony

    2 years ago
    Is there a way to set the NSURLRequest.HTTPMethod to "GET"?
    oh! that is very nice to know @Sam. thank you for that bit!
    Ah! There is a NSMutableURLRequest... 😢
    s

    Sam

    2 years ago
    That's a common pattern with the Cocoa frameworks.
    t

    Tony

    2 years ago
    very interesting. how did you figure that out?
    s

    Sam

    2 years ago
    I came to Kotlin after doing over 5 years of iOS development. It's just one of those things you learn when learning Obj-C.
    t

    Tony

    2 years ago
    ahhhh! i'm glad you told me about that quirk about NSURLSessions
    If my dispatcher for my coroutine is dispatch_get_main_queue(), do I need to bring it to the main thread when I use NSURLSession?