iOS Development — Week 7

Dr J Rogel-Salazar
6 min readOct 3, 2022

Running tasks in parallel is one of the great things we can do with computers — and mobile devices. This is called concurrency and it was the main focus for Week 7 of my iOS Development Bootcamp. In iOS, Apple provides three technologies to handle concurrency using Swift. These frameworks are designed to encapsulate units of work and dispatch them for execution. This week, we concentrated on two of them: “Grand Central Dispatch” (GCD) and “NSOperation frameworks”.

The personal challenge I had after learning these two approaches was when to pick “NSOperation frameworks” over “Grand Central Dispatch” (GCD) and vice versa. Because these APIs serve the same goal, hence the confusion about when to use which.

Below is a quick comparison of the two:

Grand Central Dispatch NSOperation A lightweight way to represent units of work that are going to be executed concurrently. GCD uses closures to handle what runs on another thread. Operations are objects that encapsulate data and functionality. Operations add a little extra development overhead compared to GCD. The system takes care of scheduling for you. Adding dependencies, canceling, or suspending code blocks is labor intensive. Allow for greater control over the submitted tasks, including some control over scheduling through adding dependencies among various operations and can re-use, cancel or suspend…

--

--

Dr J Rogel-Salazar

Data Leader, Innovation, CIO/CTO, Machine Learning, Data Science | Dynamic professional with strong understanding of AI/ML, Data Visualisation & UX Design