Enums
How enums work in Swift, a look at some of their most prominent features, and examples of situations in which they can be incredibly useful.
Weekly Swift articles, podcasts and tips by John Sundell.
Shorter and simpler articles about core Swift and iOS development concepts.
How enums work in Swift, a look at some of their most prominent features, and examples of situations in which they can be incredibly useful.
A look at a few different ways that closures can be defined and used in Swift, the flexibility of Swift’s closure syntax, and how behaviors like escaping and capturing may impact our code.
A recap of the basics of SwiftUI, Apple’s declarative new UI framework for building apps across all of their platforms. How to build custom views and modify existing ones, how to manage local state within a view, and how to compose multiple views to form new ones.
Measuring the time complexity of a piece of code is a common technique used to optimize algorithms and other kinds of functions, by estimating their cost in terms of execution time. Let’s take a look at how to use “big O notation” to describe, measure, and improve the time complexity of a few different functions.
Let’s take a look at Swift’s String API — why it’s designed the way it is, and how it deals with some of the challenges of accurately representing text in a modern app. Also, how to subscript a string, extracting and working with substrings, and how strings compare to other kinds of collections.
One way of transforming values in Swift is by mapping a collection into an array of new values, using a transform. The Swift standard library offers three main APIs for that kind of mapping — map, flatMap and compactMap. Let’s take a look at how they work.
Swift enables us to create generic types, protocols, and functions, that aren’t tied to any specific concrete type — but can instead be used with any type that meets a given set of requirements. Let’s take a look at how generics work in Swift, and how to create our own.
One way of transforming values in Swift is by mapping a collection into an array of new values, using a transform. The Swift standard library offers three main APIs for that kind of mapping — map, flatMap and compactMap. Let’s take a look at how they work.
Just like modern versions of Objective-C, Swift uses the ARC (Automatic Reference Counting) memory management model. Let’s take a look at how ARC works, and how to avoid common memory-related issues, such as retain cycles.
How an application deals with errors and unexpected values is arguably just as important as how it deals with valid results. Let’s take a look at a few key techniques that can help us provide a better user experience whenever an error was encountered within our code.
Adding animations to an app can be a great way to both delight users, and to draw their attention to certain information or actions, through motion. When deployed in the right places, animations can really make an app appear more polished and easy to use. Let’s take a look at how to get started.
Introduced in Swift 4, the Codable API enables us to leverage the compiler in order to generate much of the code needed to encode and decode data to/from a serialized format, like JSON. Let’s take a look at how to use it.
Most apps these days need a way to download data from the Internet — whether that’s files, images, or by talking to some form of web API through a format like JSON. Let’s take a look at how to do that using Foundation’s URLSession API.
Using unit tests, and other forms of automated testing, can be a great way to protect a code base against regressions and reduce the need for manual testing. Let’s take a look at how to get started.
Just like how a UIView can be added to another UIView to form a hierarchy, a view controller can become the child of another view controller. Let’s take a look at how to do that.
Grand Central Dispatch is one of the few different options available to us when it comes to asynchronous programming in Swift. Let’s take a look at how it works and how to use it.
Auto Layout has undergone quite a lot of changes and improvements over the years, in particular with the introduction of layout anchors in iOS 9. Let’s take a look at how they work.