Topic
Cocoapods
A browsable archive of writing and notes across the site.
Post
How the .af and .rx extensions work in Alamofire and RxSwift
Another lightweight post today — this time about how the .af and .rx namespacing extensions in Alamofire and RxSwift actually work. Anyone who’s used those libraries …
Post
Method dispatch in Swift
What is method dispatch? Method dispatch is the process by which the program, at runtime, decides which concrete instruction to use when a particular method is called. Dispatch is …
Post
Protocol Extension
Protocol is the most important building block in the Swift ecosystem — the scaffolding that holds everything else together. A few of the obvious wins of using protocols over …
Post
Codable && Tuple
While learning Swift, I keep finding interesting things. Codable is one of them. Today, I defined a model with a tuple type, then Xcode gave me an error. The code might look like …
Post
A Swift quiz
A puzzle showed up on Twitter the other day. It exercises overload resolution and type(of:) together. This is just a note for myself; I’ll write up MetaType separately. // …
Post
How do dockless Mac apps work?
Menu-only apps are one of the most common patterns in Cocoa-land. They don’t take up a spot in your Dock, they don’t get in the way when you’re switching across …
Post
Adding a backgroundColor to NSView
NSView is the most basic building block in Cocoa — the foundation of every Mac app’s view hierarchy, exactly like UIView is for iOS. But the dead-simple backgroundColor …
Post
The Subjects in RxSwift
All diagrams in this post are from the book RxSwift - Reactive Programming with Swift. In the Rx world, a Subject is something that’s both an observer and an observable. The …
Post
Apple Event Sandboxing
Background I’ve been working on a small Mac app that runs an AppleScript to pull data out of OmniFocus and visualize it. Problem: it kept coming back with no data. The cause …
Post
Tracking down a Shadowsocks traffic leak
Update — 2019-01-29 First thing this morning, the moment I plugged into the office network the download rate shot up to 600 KB/s. Sure enough, it was that same …
Post
Using a C file in a Swift Framework: an exploration
The problem While building a diagnostics tool, we shipped it as a single Pod containing only pure Swift code. The Swift code needed to call into a few system C library features — …
Post
Testing Swift code that uses system singletons in 3 easy steps
Original: Testing Swift code that uses system singletons in 3 easy steps Original author @johnsundell Most apps built on Apple platforms lean on singleton-based APIs. From …
Post
Avoiding singletons in Swift
Original: Avoiding singletons in Swift Original author & Copyright @johnsundell “I know singletons are bad, but…” — you hear it all the time when developers are …
Post
Different flavors of dependency injection in Swift
Original: Different flavors of dependency injection in Swift Original author & copyright: @johnsundell In previous posts we’ve looked at several ways of using dependency …
Post
What is LLVM
What is LLVM? The secret behind Swift, Rust, Clang, and more Understanding how a compiler emits native machine code makes it dramatically easier to invent a new language or enhance …
Post
In-app purchase
If your app ships on the App Store, in-app purchase (IAP) is something you can’t really avoid. Last year’s spat between WeChat tipping and Apple put IAP in the …
Post
Dependency injection using factories in Swift
Original: Dependency injection using factories in Swift Original author & copyright: @johnsundell Dependency injection is one of the key tools for making code more testable. …
Post
Modularising Xcode projects
Original: Modular Xcode projects Author & Copyright @pepibumur Translator: @OgreMergO Building a modular Xcode project takes a real understanding of project structure and the …