Suppose we have code that executes an animation closure nested inside a Dispatch Work Item.

Here are 3 versions of this code. Can you tell which one introduces a retain cycle? (click for mobile-friendly gist)

Thanks to Pablo Stanley for these amazing illustrations!

This is part 3 of my concurrency series. Check out Part 1 and Part 2 if you missed them.

In my earlier discussion of sync, async, serial, and concurrent, I alluded to some pitfalls that you might encounter while working with concurrency. That’s our main topic for this article. Afterwards, I will wrap up this series with a summary and some general advice.


Priority Inversion and Quality of Service

Priority inversion happens when a high priority task is prevented from running by a lower priority task, effectively inverting their relative priorities.

This situation often occurs when a high QoS queue shares a resources with a low…

This is part 2 of my concurrency series. If you missed part 1, check it out here.

In part 1, we explored the differences between synchronous and asynchronous execution when dispatching tasks using GCD. Now, we’re going to focus on what happens in the queue after you dispatch your task.

Serial vs Concurrent

Serial and concurrent affect the destination — the queue in which your work has been submitted to run. This is in contrast to sync and async, which affected the source.

A serial queue will not execute its work on more than one thread at a time, regardless of how many…

Throughout this concurrency series, I am going to cover the different types of queues in Grand Central Dispatch (GCD.) More specifically, I will explore the differences between serial and concurrent queues, as well as the differences between synchronous and asynchronous execution.

If you’ve never used GCD before, this series is a great place to start. If you have some experience with GCD, but are still curious about the topics mentioned above, I think you will still find it useful, and I hope you will pick up one or two new things along the way.

I created a SwiftUI companion app…

Thanks to Arpit Sharma for the inspiration!

Cycles… no, not the fun kind shown above. I mean strong reference cycles, the kind that causes entire view controllers to leak in your iOS app. More specifically, I want to talk about the use of [weak self] inside of Swift closures to avoid reference (or retain) cycles, and explore cases where it may or may not be necessary to capture self weakly.

I learned about the topics discussed in this article from reading Apple docs, a variety of blog posts and tutorials, and through trial & error and experimentation. …

Photo by Patrick Ward on Unsplash

In my earlier posts, I mentioned how personal projects helped me stay motivated while I was learning programming. In this post I will talk about the first personal project that I built back in 2017, covering all steps from idea to final version.

I covered the purpose of this project back in this post, but as a quick recap it is a macOS application intended for my previous day job as an IT support specialist. The app was meant to save us time by displaying relevant information about the user we were helping (their access rights, software licenses, etc).


Credit: Sharon Pittaway

In Part 1 I discussed two different ways to perform 2D drawing on iOS, both of which are CPU-based. The first one performed ok on the iPhone but very poorly on the iPad (17 fps average), while the second one delivered great performance and only incurred about 25% CPU utilization on average.

I mentioned at the end of Part 1 that I wasn’t very happy with the single-threaded nature of my final result. In this post, I will cover two different ways to draw that leverage the parallel nature of the GPU.

Core Graphics uses the CPU for rendering, while…

Source: Tim Arterbury — Unsplash

As I was building my recently released drawing game, I explored different ways to perform 2D drawing on iOS. Throughout this 2-part series, I will share what I’ve learned by comparing the performance of 4 distinct ways to draw on the platform. All 4 techniques will look exactly the same in terms of the final drawn image, but as we will see, their implementation and performance will vary wildly.

This is by no means a definitive guide for 2D drawing. I am still learning about all of this, and I’ll be updating this article as I learn new information. …

Credit: Susan Yin

Last week I published my first open source library, QuickTicker. It’s a Swift library that lets you create simple ticker animations using one line of code. The result looks like this:

Besher Al Maleh

Self-taught iOS developer interested in all things iOS

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store