Learn more about Swift

Understanding Swift’s OptionSet

Published on: August 18, 2020

Every once in a while I look at a feature in Swift and I fall down a rabbit hole to explore it so I can eventually write about it. The OptionSet protocol is one of these Swift features. If you’ve ever written an animation and passed it a list of options like this, you have […]

Read post

Using Codable with Core Data and NSManagedObject

Updated on: April 5, 2021

If you’ve ever wanted to decode a bunch of JSON data into NSManagedObject instances you’ve probably noticed that this isn’t a straightforward exercise. With plain structs, you can conform your struct to Codable and you convert the struct from and to JSON data automatically. For an NSManagedObject subclass it’s not that easy. If your Core […]

Read post

Setting up a Core Data store for unit tests

Updated on: August 4, 2020

Unit testing is an important skill in the toolbox of any engineer. Knowing how to write a reliable, robust test suite helps you write reliable and robust code. If you’ve followed my introduction to unit testing part one and part two, or if you’re experienced with unit testing you know that your tests should run […]

Read post

How to change a UICollectionViewListCell’s separator inset

Updated on: September 30, 2020

In WWDC2020’s session Lists in UICollectionView a slide is shown where a UICollectionViewListCell’s separator inset is updated by assigning a new leading anchor to separatorLayoutGuide.leadingAnchor. Unfortunately, this doesn’t work in when you try to do it. To set the separator inset for a UICollectionViewListCell you can update the leading anchor constraint by overriding updateConstraints in […]

Read post

How to add a custom accessory to a UICollectionViewListCell?

Updated on: September 30, 2020

Apple provides several accessory types that you can use to apply certain affordances to a UICollectionViewListCell. However, sometimes these options don’t suit your needs and you’re looking for something more customizable. To add a custom accessory to a list cell instead of a standard one, you use the .custom accessory type. The initializer for this […]

Read post

How to add accessories to a UICollectionViewListCell?

Updated on: September 30, 2020

In iOS 14 Apple added the ability for developers to create collection views that look and feel like table views, except they are far, far more powerful. To do this, Apple introduced a new UICollectionViewCell subclass called UICollectionViewListCell. This new cell class allows us to implement several tableviewcell-like principles, including accessories. Adding accessories to a […]

Read post

How to add custom swipe actions to a UICollectionViewListCell?

Updated on: January 6, 2022

In iOS 14 Apple added the ability for developers to create collection views that look and feel like table views, except they are far, far more powerful. To do this, Apple introduced a new UICollectionViewCell subclass called UICollectionViewListCell. This new cell class allows us to implement several tableviewcell-like principles, including swipe actions. You can add […]

Read post

Configure collection view cells with UICollectionView.CellRegistration

Updated on: September 30, 2020

In iOS 14 you can use the new UICollectionView.CellRegistration class to register and configure your UICollectionViewCell instances. So no more let cellIdentifier = "MyCell", no more collectionView.dequeueReusableCell(withReuseIdentifier: "MyCell", for: indexPath) and best of all, you no longer need to cast the cell returned by dequeueReusableCell(withReuseIdentifier:for:) to your custom cell class. Adopting UICollectionView.CellRegistration in your project […]

Read post

What’s the difference between Float and Double in Swift

Updated on: July 31, 2020

A Double and Float are both used to represent decimal numbers, but they do so in slightly different ways. If you initialize a decimal number in Swift using as shown below, the Swift compiler will assume that you meant to create a Double: let val = 3.123 // val is inferred to be Double The […]

Read post

Understanding property wrappers in Swift with examples

Updated on: July 7, 2025

Property wrappers are a feature that was introduced in Swift 5.1 and they play a huge role in SwiftUI and Combine which are two frameworks that shipped alongside Swift 5.1 in iOS 13. The community was quick to create some useful examples that were embraced by folks relatively quickly. As a user of property wrappers, […]

Read post

Expand your learning with my books

Practical Swift Concurrency (the video course) header image

Learn everything you need to know about Swift Concurrency and how you can use it in your projects with Practical Swift Concurrency the video course. It contains:

  • About ten hours worth of videos and exercises
  • Sample projects that use the code shown in the videos.
  • FREE access to the Practical Swift Concurrency book
  • Free updates for future iOS and Swift versions.

The course is available on Teachable for just $89

Enroll now