I have a local notification that is set when a user taps a button. I want to send this to the background thread and then update the UI. Is this a safe way to do it?
DispatchQueue.global(qos: .background).async { // sends registration to background queue
center.add(request, withCompletionHandler: {(error) in
if let error = error {
print(error)
}
})
DispatchQueue.main.async {
try! self.realm.write {
self.realm.add(task)
self.updateData()
}
}
}