Multithreading in iOS| Difference between GCD and NSOperation

Basics of concurrency in iOS.

override func viewDidLoad() {super.viewDidLoad()doSomeTimeConsumingTask() // takes 5 seconds to respond
tableView.reloadData()
}
override func viewDidLoad() {super.viewDidLoad()DispatchQueue.global(qos:.userInteractive).async {
self.doSomeTimeConsumingTask() // takes 5 seconds to respond
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}

NSOperation and Grand Central Dispatch

Benefits of NSOperation

“ when you want more control over queue (all above mentioned) use NSOperation and for simple cases where you want less overhead (you just want to do some work "into the background" with very little additional work) use GCD.

If you enjoyed reading this post, please share and give some clapps so others can find it 👏👏👏👏👏 !!!!

iOS and tvOS developer, dreamer, photographer 🤨