HTTP in Swift, Part 8: Request Options
In part 8 of his series on building a Swift HTTP framework, Dave Delong demonstrates how we can customize individual request behavior. Dave does this by declaring type-safe request options that dynamically alter requests when applied by the request loader.
Posted on January 21, 2021
#network
#http
What type is self in a Swift self-executing anonymous closure used to initialize a stored property?
We have likely all (perhaps unknowingly) used a self-executing anonymous closure in our Swift code. Indeed, one use is when initializing stored properties for a type. In this post, Jesse Squires describes a situation he encountered when using such a closure that led to the discovery of unexpected behavior in Swift.
Posted on January 19, 2021
#closure
Result in Swift: Getting started with Code Examples
Available since Swift 5, the Result type allows us to define a success and failure case for a failable operation. In this post, Antoine van der Lee demonstrates some of the lesser-known extensions from the Swift standard library that can be used with this type.
Posted on December 20, 2020
#result
HTTP in Swift, Part 7: Dynamically Modifying Requests
Part 7 of Dave Delong's series on building a Swift HTTP framework looks at dynamically modifying requests. Dave demonstrates how modifying requests as they pass through the framework chain is a powerful tool that can be applied in several situations.
Posted on December 17, 2020
#network
#http
Actors are reference types, but why classes?
The recently announced Swift Concurrency Roadmap includes the proposal of an Actor reference type, similar to a class type. In this whitepaper, Chris Lattner explores the behavior and requirements of actors and proposes that Actor types be modeled as a new kind of nominal reference type in Swift.
Posted on December 16, 2020
#concurrency
#evolution
#actor
HTTP in Swift, Part 6: Chaining Loaders
In part 6 of his series on building a Swift HTTP framework, Dave Delong looks at adding the ability to chain HTTP loading requests. To achieve this, Dave adapts his HTTPLoading protocol, formalizing his concept of a next loader.
Posted on December 10, 2020
#http
#network
Swift Concurrency Proposal Dependencies
The Swift Concurrency Roadmap was recently published, which outlined proposed additions and changes to the language to support concurrent programming. It's a great read, and very informative. However, if you are looking for a quick overview of the dependencies relating to the concurrency roadmap, this diagram from Doug Gregor is a good place to start.
Posted on December 9, 2020
#concurrency
#diagram
Codable synthesis for enums with associated values
Swift 4 introduced support for automatically synthesizing conformance to the Encodable and Decodable protocols. It's a useful feature, most likely used by any application which handles JSON-based network requests. This Swift evolution pitch from Dario Rexin proposes extending auto-synthesis of these conformances to enums with associated values. I'm sure we will see this in an upcoming Swift version.
Posted on December 8, 2020
#evolution
#enum
#codable
Statically computed default property values
As John Sundell writes in the introduction to this short post, defining default values for our API properties can improve the usability of our APIs while still enabling customization when needed. With that in mind, John shares a tip for setting a default property value while also reminding us of a crucial difference between a lazy property and a non-lazy one.
Posted on December 7, 2020
#property
#lazy
Testing the UI without UI Testing in Swift
Testing the user interface is an essential part of software development. Unfortunately, UI testing frameworks such as Apple's XCUITest are often unreliable and slow. However, there are other methods of testing the user interface, and in this post, Joe Masilotti shows us how to write UI tests using XCTest, Apple's unit testing framework.
Posted on December 6, 2020
#testing