This is part of a series of posts this week about some ways in which I use Apple’s Shortcuts app. As a respectable millennial couple, Sarah and I plan our meals by adding an event into our shared calendar. What we found as we discussed the options was that the entry of these was made slower by having to select the time and, crucially, prefixing the title with our meal emoji of choice: 🍽️. As you…
This is part of a series of posts this week about some ways in which I use Apple’s Shortcuts app. Sarah and I use Notes to share a folder of recipes and Reminders for sharing a grocery list. Notes allows our recipes to have images, be updated with tweaks that we make and crucially stored so we can always find them. Reminders lets us use the kitchen HomePod to say “Hey Siri add [insert item here]…
Result builders in Swift are a great API for creating DSLs (Domain Specific Languages). In recent projects, we have used them to capture details about telemetry events and defining a set of feature flags that can be locally overridden by developers. We have a Flag type that is generic over the value the feature flag will return. We also have OverridableFlag which defines a flag that can be…
The Internet Engineering Task Force documents the issue of two pairs of terms common in computing. One of the pairs is around the terms master and slave, which it states “ is an oppressive metaphor that will and should never become fully detached from history. ” It’s questionable whether git’s use of master derives from this usage, I’m not sure whether it matters because the connotation could…
When making views that display information from the internet, a common pattern is to have a view that displays three states: an initial view while content is being fetched and then either the view to display the content or a view to show there was an error. In this post we’ll walk through creating a SwiftUI view to load content using a Combine publisher, showing views provided by the user for our…
It’s common when referring to strings from multiple places to create a centralized location where they are defined. For keys used for accessing UserDefaults values, that may be a static property in an enum, which is used to act as a namespace for user default keys. This allows you to use this property rather than a string literal, so that the compiler can help ensure the wrong value is not used,…
In this article, I will explain how I made a publisher that takes an array of publishers and combines them into an array output. The code for the resulting publisher is on GitLab and is up-to-date with Xcode 11 beta 5. Prelude During a workshop run by Antoine van der Lee at Swift Island this year, we were tasked with using Combine to add checks to a simple four page form. Each page progressively…
Apple’s WWDC 2018 session Managing Documents In Your iOS Apps explains best practices for dealing with documents and the topic of a URL’s security scoped resource is discussed: This URL has a security scoped resource attached to it. You can think of this resource as a permissions token granted to you by the system, and accessing this token would allow your app to access this document. We can start…
Imagine we have a Version type with major, minor and patch integer values. struct Version : Equatable { let major : Int let minor : Int let patch : Int } Here, Swift 4.1 automatically generates the == function required for the Equatable conformance, which is really really nice. However, we might also like to make it Comparable so that we could compare the app version to a given version we create…
When writing collection view layouts, we are often subclassing UICollectionViewFlowLayout to gain access to the extra options that are provided. This is really helpful because it means we can use all of the plumbing provided by Apple for these including great support in Interface Builder for its properties. There are six properties definied on UICollectionViewFlowLayout that can be set by users of…