What is a RunLoop Anyway? Swift and iOS Guide

Threads are not all that there is to getting stuff done.

Steven Curtis
4 min readAug 15, 2022
Photo by Ross Stone on Unsplash

Apple Say

Apple has enabled the iOS SDK to handle user events and trigger responses within the application through use of the event queue.

Eh?

A run loop keeps your thread busy when there is work to do and put your thread to sleep when there is none.

In other languages a run loop might be called an event loop.

A Simple Example

Let’s take an example about how views are laid out.

When a user interacts with an application, the event is added to the event queue, which can then be handled by the application and potentially dispatched to other objects in the application. Once the events are handled, they then return control to the main run loop and begin the update cycle, which is responsible for laying out and drawing views.

Then

--

--