Entries with the swift tag

Pull request Set `updateDelegate` when a provider invalidates on composed-swift/Composed

Opened 6th July, 2020

Basic Sections were not propagating updates if added via a call to invalidateAll. This is to address #2.

The issue can be recreated by using a SegmentedSectionProvider when switching to a segment that contains a Section (SectionProvider works I think)

This commit alone is likely not enough to fix this issue; updateDelegate should probably be set to nil for removed Sections, and should probably be set in more places.

My Swift Package Manager Release Workflow

Published 18th June, 2020

I am currently maintaining numerous Swift Packages that don't receive a constant flow of updates, but do receive updates when new Swift updates come out, or as I think of useful additions.

To ensure that I can make some of these less frequent updates without too much friction and with confidence in their correctness I rely heavily on GitHub Actions, which I'll go over in this blog post.

Read More

Persist v1.0.0-rc1

Released 30th May, 2020

Release Notes

Release candidate 1 for 1.0 stable release

Has lots of tests but little documentation. API has changes a lot since initial 0.1.0 but Iā€™m happy with it now. Hopefully it is consistent and (once docs are added) easy to use.

Capturing More Than `self`

Published 14th May, 2020

A common pattern when using closures in Swift is to add [weak self] in the captures list to hold a weak reference to self and avoid a retain cycle. This is then often followed by the following:

guard let self = self else { return }

But I often forget that capture lists can capture other variables in the current scope, so I thought I'd highlight some other use cases.

Read More

HashableByKeyPath framework release 1.0.0

Published 30th April, 2020

Today I have released the 1.0.0 version of a Swift package that aids with adding Equatable and Hashable conformance by using KeyPaths.

The package is available on GitHub.

I created the Swift Playground that sparked this concept in December 2018, so this concept has been rattling around in my brain for a couple of years. The API has changed a lot since the original concept, but the core has stayed the same: a protocol that requires a single function to be implemented that uses KeyPaths to synthesise Equatable and/or Hashable conformance.

Read More

Partial framework release 1.0.0

Published 10th July, 2019

Today marks 1 year since I released a blog post demonstrating an implementation of Partial in Swift, and it also marks the release of the 1.0.0 version of a Swift package for Partial.

The package is available on GitHub and supports SwiftPM, Carthage, and CocoaPods.

This blog post will go over some of the changes that have been made since the original blog post, my rationale when making certain decisions, and how I have thought about maintenance. If you want to try out Partial and see how it can be used head over to the GitHub page.

Read More

Partial in Swift

Published 10th July, 2018

Structs are incredibly useful in Swift, especially when representing static read-only data. However, the values of a struct often come from multiple sources, such as view controllers, network requests, and files on disk, which can make the creation of these structs cumbersome.

There are numerous methods to work around this, but each have their downsides. One of these methods is to change the struct to a class and update the properties to vars, but this removes the advantages of read-only structs. Another is to make a "builder" object, but the API of this object must be kept in-sync with the object is wraps.

Partial eliminates these problems by providing a type-safe API for building structs by utilising generics and KeyPaths. Although I learned of the concept of Partial through TypeScript ā€“ which provides Partial as a built-in type ā€“ the Swift implementation supports many more use cases.

Read More