TIL
A collection of short, unsorted notes on things I’ve learned, mostly about development for Apple platforms. Inspired by Simon Willison and Chris Eidhof.
Today, while working on a major refactor of InterposeKit, I learned that KVO in Objective-C works by dynamically creating a subclass at runtime. It’s called NSKVONotifying_OriginalClass
and it overrides the getter and setter of the observed property to include the observation logic. When removing the observation, the runtime even restores the original class and cleans up after itself.
Today I learned how to convert YAML to JSON directly from the command line using yq (not to be confused with the Python implementation): yq eval data.yaml -o json -P > data.json
Today I learned that Group
and ForEach
have public support for accessing their subviews starting in iOS 18 and macOS 15 using the Group.init(subviews:transform:)
and ForEach.init(subviews:content:)
initializers, respectively.
Today I learned that wrapping a Swift string literal in pound signs removes the need to escape quotes. Instead of "{\"key\": \"value\"}"
you can write #"{"key": "value"}"#
.
Today I learned that NSAlert
allows setting a custom icon image to replace the default app icon.
Today I learned that submenus on iOS display a bold chevron on the left when presented on an iPhone and a more subtle chevron on the right when presented on an iPad.
Today I learned that when moving items in a list on iOS, UIKit uses target indices as they are after deletion, while SwiftUI uses them as they were before deleting the moved item.