I have an app that is developed with old swift code. now I'm updating it to latest swift syntax. While updating I found difficult in dispatch queue, here it's giving two warnings as global(priority) was deprecated in ios 8 and background was deprecated in ios 8.
DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.background).async(execute: { [weak self] in //Getting warning in this line
if let strongSelf = self {
strongSelf.populateOutBoundContacts()
strongSelf.lookForContactsToPresent()
}
})
The syntax was changed to DispatchQueue.global(qos: DispatchQoS.QoSClass)
. You don't need to call async(execute)
, you can directly call async
and write the code to be executed in the closure.
DispatchQueue.global(qos: .background).async{ [weak self] in
if let strongSelf = self {
strongSelf.populateOutBoundContacts()
strongSelf.lookForContactsToPresent()
}
}
When updating old code, I strongly suggest going through the documentation of the respective classes and using Xcode's auto completion, it can save you a lot of time when looking for the new syntax/methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With