Skip to content

Instantly share code, notes, and snippets.

@SlappyAUS
Created November 29, 2020 09:22
Show Gist options
  • Select an option

  • Save SlappyAUS/3898651e8664ce8ebfea1ae9cddd8158 to your computer and use it in GitHub Desktop.

Select an option

Save SlappyAUS/3898651e8664ce8ebfea1ae9cddd8158 to your computer and use it in GitHub Desktop.
Custom Queues #swift #async #queue
// A background queue used to save and load the model data.
private var background = DispatchQueue(label: "Background Queue",
qos: .userInitiated)
// Save the data on a background queue.
background.async { [unowned self] in
do {
try data.write(to: self.getDataURL(), options: [.atomic])
} catch {
print("*** An error occurred while saving the data: \(error.localizedDescription) ***")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment