Data-Driven UI with UIKit
Preserving the theme of simplicity let’s make use of one of my favorite method from UIKit - layoutSubviews
and build a data driven UI system.
Preserving the theme of simplicity let’s make use of one of my favorite method from UIKit - layoutSubviews
and build a data driven UI system.
Swift await
works by capturing the context and suspending the execution until the called async
method returns. Another thing that works similarly by capturing the surrounding context is an escaping closure. So async-await
calls can be imagined as equivalent to escaping closure. Whenever you see a method with async
mentally replace that method with a escaping completion handler.
Note: This is a Swift rewrite of the original article published in 2020
The maths required for SwiftUI custom layout reminds me of the days before AutoLayout and the constraints based system. The good thing is that Simple Layout Engine already provides a nice system to handle all the maths involved. To demonstrate I would use build the subset of the demo app from the WWDC session on this topic: Compose custom layouts with SwiftUI.
UnfairLock
seems to be causing a lot of confusion for Swift developers. Every once in a while I run across some incorrect implementation that reads like: