Give your simulator superpowers

RocketSim: An Essential Developer Tool
as recommended by Apple

How to create a Dynamic Pager View for onboardings

A pager view in SwiftUI like we know UIPageViewController in UIKit didn’t exist until iOS 14 and macOS 11.0. Using the PageTabViewStyle on a TabView will result in a swipeable set of pages. However, what if you want to support iOS 13? And how would you do something similar on macOS Catalina? On top of … 

 

How and when to use Lazy Collections in Swift

Lazy collections are similar to a regular collection but change the way how modifiers like map, filter, and reduce are processed. In my experience, they haven’t got as much attention as they should as they can be more performant in certain cases. You might be more familiar with lazy vars, but have you used the … 

 

How to use Variadic parameters in Swift

Variadic parameters make it possible to pass zero or more values of a specific type into a function. It can be a clean alternative for methods that often work with one element, and you don’t want to create an array of components for just a single value on the implementation level. The great thing about … 

 

XCTExpectFailure: Expected test failures explained with code examples

XCTExpectFailure was introduced in Xcode 12.5 and allows marking test failures as expected. The first time I read about this new API I was kind of confused: why wouldn’t we use methods like XCTAssertThrowsError instead? I continued my journey and quickly realised this API is a welcome addition to the XCTest framework. In fact, it … 

 

Lazy var in Swift explained with code examples

A lazy var is a property whose initial value is not calculated until the first time it’s called. It’s part of a family of properties in which we have constant properties, computed properties, and mutable properties. A lazy property might be lesser known to beginners in Swift but are actually super valuable once you know … 

 

Closures in Swift explained with Code Examples

Closures in Swift can be challenging to understand with types like trailing closures, capturing lists, and shorthand syntaxes. They’re used throughout the standard library and are part of the basics you need to know when writing Swift code. Xcode will help us most of the time with the right syntax using autocompletion but it’s good … 

 

What is a Computed Property in Swift?

Computed properties are part of a family of property types in Swift. Stored properties are the most common which save and return a stored value whereas computed ones are a bit different. A computed property, it’s all in the name, computes its property upon request. It can be a valuable addition to any of your … 

 

SwiftLee 2020 In Review: Most read blog posts

Every year I’m looking back at what I achieved with SwiftLee as well as what I want to achieve in the upcoming year. I did this in 2018, 2019, and I’m doing the same in this blog post for 2020. 2020 is definitely not comparable to the years before due to COVID and all its … 

 

Getting started with associated types in Swift Protocols

Associated types in Swift work closely together with protocols. You can literally see them as an associated type of a protocol: they are family from the moment you put them together. Obviously, it’s a bit more complicated to explain how associated types work but once you get the hang of it, you’ll be using them … 

 

Result in Swift: Getting started with Code Examples

The Result enum is available since Swift 5 and allows us to define a success and failure case. The type is useful for defining the result of a failable operation in which we want to define both the value and error output type. The standard Swift library adds more functionality to the result type which …