Learn Something New

A series of one-off tutorials designed to help expand your knowledge of Swift, SwiftUI, and more. Sometimes they will be practical and contain knowledge you can apply straight away, other times we'll just explore fun quirks and curiosities of coding for Apple platforms, but you'll definitely learn something new!

Swift

Tutorials about the Swift language itself.

Using Codable with protocols

17:16

1. Using Codable with protocols

It's easy to encode an array of objects that have the same type, but how can you handle an array of objects with a different type? In this tutorial I'll show you exactly how to do it with a simple and effective approach.

The pitfalls of string bridging

23:09

2. The pitfalls of string bridging

Swift's strings are designed to work flawlessly with languages around the world, but sometimes – just sometimes – you need to be careful using them. Let's explore why…

Inside Swift hashing

31:41

3. Inside Swift hashing

Did you know it's possible for two things to be considered equal even when they aren't the same? Let's look at how hashing works in Swift, how we can tweak it for performance, what problems it can cause, and most importantly how to make sure those problems never strike your code.

Printing vs dumping

11:41

4. Printing vs dumping

Everyone knows the print() function, not least because it's often our first port of call when debugging. But printing in Swift can be so much more powerful! Let's dig in…

Actors and actor reentrancy

17:01

5. Actors and actor reentrancy

Swift's actors are an incredibly powerful way to schedule work safely, but they have a catch: actors allow reentrant code, which can cause surprising problems. Let's explore how actors work, and how reentrancy can catch you out…

Managing your app's memory high water mark

27:51

6. Managing your app's memory high water mark

Swift loves value types because they are fast and light, but so much of our work builds on older APIs powered by UIKit and other Objective-C APIs, where it's easy to hit memory problems. Let's look at a smart solution, and how it also impacts modern frameworks like SwiftData…

Making optionals easier

13:18

7. Making optionals easier

Optionals are a power feature in Swift, but they can be a little clumsy to work with. In this article I'll introduce four ways to make optionality easier to handle, including ditching them entirely.

Power up your dictionaries

14:00

8. Power up your dictionaries

Dictionaries provide simple and fast key-value storage, but they have some superpowers that can really help clean up your code. Let's take a look at them now…

Mangling and demangling

12:08

9. Mangling and demangling

In a world of huge projects and countless frameworks from Apple and third parties, how can Swift refer to every type uniquely? The answer is name mangling, and if you're careful it's useful in your code too.

Xcode

Tutorials to help you make better use of Xcode.

Personalizing your Xcode header

16:11

1. Personalizing your Xcode header

We make new files in Xcode all the time, but if you spend just a few minutes you can customize the comments that are automatically placed at the start to make them suit you much better.

Smarter breakpoints

17:39

2. Smarter breakpoints

Although using print() calls is often the first thing we reach for when diagnosing a problem, let me walk you through a handful of smarter ways to debug your code with breakpoints.

Over to watchpoints

10:15

3. Over to watchpoints

We already looked at advanced uses of breakpoints, but now I want to introduce you to their close friend: watchpoints. These tell you where a value changed, even when you don't know!