HTTP in Swift, Part 5: Testing and Mocking
Dave Delong's blog series on building a Swift HTTP framework is full of useful tips, and this particular entry is no different. In this part, Dave looks at testing and mocking and shows us how using an interface rather than a concretion enhances the utility and testability of his code.
Posted on December 3, 2020
#network
#http
What went wrong with the libdispatch. A tale of caution for the future of concurrency.
Apple's Grand Central Dispatch (GCD or libdispatch) provides support for concurrent code execution on multicore hardware. It aims to remove the need for developers to directly manage threads, enabling them to instead think in terms of queues of work. In this very interesting post, Thomas examines some of the problems of using libdispatch, offering words of caution for the future of concurrency in Swift.
Posted on December 2, 2020
#concurrency
SwiftUI’s Grid Views
SwiftUI's grid views arrange their child views in a horizontal or vertical grid. However, how they layout their child views can be surprising, and in this post, Florian Kugler from Objc.io examines three particular grid view layout scenarios and explains how the layout algorithm works.
Posted on December 1, 2020
#swiftui
#layout
Availability checking for protocol conformances
Swift's availability checking feature currently allows us to check if a referenced declaration is available at runtime. In this post from the official Swift forums, Slava Pestov details an extension to this feature which provides the ability to check the availability of protocol conformances.
Posted on November 30, 2020
#evolution
#protocol
Combine and Swift Concurrency
The Swift Core Team recently provided an excellent roadmap and series of language proposals outlining the future of concurrent programming in Swift. In this post, Joseph Heck looks at what the roadmap means for the Combine framework and how it might gain from the proposed concurrency concepts.
Posted on November 26, 2020
#combine
#concurrency
SwiftUI View Lifecycle
When working with UI frameworks, it's helpful to understand the lifecycle of the views which make up our interface. Knowing what and when events will occur enables us to perform our actions at the right time. In this post, Vadim Bulavin explores the three phases of the SwiftUI view lifecycle, describing the series of events that happen from the creation of a view to its destruction.
Posted on November 25, 2020
#swiftui
#lifecycle
HTTP in Swift, Part 4: Loading Requests
Part 4 of Dave Delong's series on building a Swift HTTP framework looks at how to send requests and receive responses. It's another excellent entry in the series, and Dave succeeds in demonstrating how simplicity is the ultimate sophistication.
Posted on November 24, 2020
#network
#http
How an Hstack Lays out Its Children
As Chris Eidhof states in the introduction to this post, SwiftUI's layout system is, for the most part, intuitive to use. However, there are times when we encounter puzzling layout behaviors, and here Chris provides a detailed explanation of how one particular container view, an HStack, lays out its child views.
Posted on November 23, 2020
#swiftui
#layout
[Proposal] Static member lookup on protocol metatypes
Swift currently supports static member lookup on concrete types. This improves call-site legibility by enabling us to use leading dot syntax when accessing static values. In this Swift evolution pitch, Sam Lazarus proposes extending static member lookup to protocol metatypes. This would be a nice addition, and would not have any effect of source of API stability.
Posted on November 22, 2020
#evolution
#protocol
Parsing Tricky JSON With Codable in Swift
Parsing JSON is sometimes not as straightforward as we would like it to be, and we might find ourselves dealing with malformed JSON payloads. In this post, Andrés Ibañez shares his tips for parsing tricky JSON using Swift's Codable protocol.
Posted on November 18, 2020
#codable
#json