-4

I'm following a tutorial on the internet for creating an app, but it's a bit old. During the tutorial, he uses this code:

dispatch_async(dispatch_get_main_queue(), { () -> Void in
    // Action
})

The problem is that - I think - this type of code was deprecated with Swift 4: what do I have to do to "translate" it and use it in my app?

jscs
  • 63,694
  • 13
  • 151
  • 195
Nicop.dev
  • 50
  • 1
  • 8

1 Answers1

1

swift 4.2 / Xcode 10.1

if you need to run your code block in the main thread:

DispatchQueue.main.async {
      //your code block
}
FRIDDAY
  • 3,781
  • 1
  • 29
  • 43