December 16, 2020

Composable Architecture and UIKit: Collection Views

In the first installment of this blog series on UIKit and The Composable Architecture we talked about how we can reduce the boiler plate required to setup a view controller powered by a Store. This post will build on that and see what it takes to implement a collection view. The first thing you need to know about rendering items from a TCA Store in a table or collection view is that we won’t be referring to the items by IndexPath.

Read more...
December 16, 2020

Composable Architecture and UIKit: The View Controller

This will be the first in a — hopefully — long series of posts about building a UIKit app using The Composable Architecture, developed by Brandon Williams and Stephen Celis of PointFree.co fame. If you do not subscribe to Point-Free I highly suggest you take a look at some of the free episodes to get you started. If you’d like to sign up, here’s a referral link that’ll give me some credit!

Read more...
June 11, 2020

Black Lives Matter

I’ve been meaning to post something online for weeks now. I’ve made excuses for myself. Excuses like “I don’t have a very big following, nothing I say will make a difference”. But that’s fucking bullshit. Every voice matters. The last few days have made me realize that I don’t know close to enough about the struggles of minorities. Of course I am well aware of the structural racism in our world.

Read more...
April 29, 2020

Clicking Background Windows

Here’s a little reminder that by holding down command you can send clicks to a view in the background without the current app losing focus. Handy when a big iPad simulator and Xcode window doesn’t fit side-by-side!

April 25, 2020

Efficient Text Navigation on macOS

A while back I noticed my wife using the trackpad on her MacBook Air to select text and felt this inner little nerd know-it-all poke my brain. And so the idea for this blog post was born. I cannot remember when or how I learned these tricks. Probably as an accident when I was learning HTML as a ten year old, writing all caps tags. Anyway, I’ve been thinking about jotting down these tips for a long time, so here we go.

Read more...
January 30, 2020

Using Self Executing Closures to Run Code in SwiftUI

Not being able to run arbitrary code in SwiftUI view builders can be quite annoying. The other day I realized it’s possible to use self executing closures to work around this! Here’s a contrived example that creates a stretchy header: struct ScrollThing: View { var body: some View { ScrollView { VStack(spacing: 0) { GeometryReader { g in Color.white .offset(y: { let offsetY = g.frame(in: .global).minY return offsetY > 0 ?

Read more...
December 25, 2019

UICollectionView Ergonomics

One of my favorite things in UIKit is UICollectionView. I love how versatile it is. With iOS 13 it got even better with the diffable data source and compositional layout APIs. However, when dealing with collection views there’s a lot of boiler plate one has to take care of. In this post I want to share some of the code I’ve written to make working with collection views a bit nicer.

Read more...
October 3, 2019

Combine's Sequence Publisher Missing First Element

Just had a fun run in with a bug in Combine. Any Sequence can produce a Publisher that publishes each element in the sequence when you subscribe to it. You might have a custom sequence implementation that counts from 1 to 9: final class Incrementer { var value = 0 func next() -> Int? { value += 1 guard value < 10 else { return nil } return value } } extension Incrementer: Sequence { func makeIterator() -> AnyIterator<Int> { return AnyIterator { self.

Read more...
October 2, 2019

Plantry 3.4: Search

After a brief holiday in 3.3, Search is now back in Plantry and it’s better than ever. Built using SQLite’s FTS4 it enables our users to filter recipes based on ingredients, their name and so on. This is something we’ve been wanting to do a long time, feels great to finally ship. Many thanks to Gwendal Roué for his amazing work on GRDB.swift and the quick responses to issues. I also finally had a use for the quintessential reactive programming example: debouncing search queries!

Read more...
October 1, 2019

Using Combine to Supplement Delegates With Publishers

Anyone who’s ever written an iOS app has come in contact with the delegate pattern. It’s a great pattern and fills an important role in iOS development. However, sometimes when you’re writing your own custom classes it can feel like a bunch of boilerplate just to notify a delegate that something happened. You might resort to adding a couple of callback properties instead, but those come with their own baggage.

Read more...