From the course: iOS Development: Threading and Grand Central Dispatch

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Dispatching synchronously

Dispatching synchronously

From the course: iOS Development: Threading and Grand Central Dispatch

Start my 1-month free trial

Dispatching synchronously

- When we talk about synchronous tasks, these are tasks that are ran in order. When you run a task, everything that comes later, has to wait for the first task to finish. Because of this behavior, synchronous programming is predictable, which is one of it's advantages. Synchronous programing may not be popular, but it can come in handy in some ways. Suppose you have an app where a user has to login, accept the terms and conditions, before finally accessing their dashboard. This is an example of how it would look in code. You can easily read this code from top to bottom. Once the user is logged in, we check if they have accepted the terms and conditions, based on the response we get we can proceed to either show the terms and conditions screen, or proceed to the dashboard. If the order of completion of a task is important to you, you should consider using dispatch.sync. It's important to know, apple wants that calling…

Contents