Posts by year


Nib-backed Collection Views

5 minute read

When working with collection views (and table views) in UIKit, you have to implement a data source which feeds the collection view with cells. Since a collection view often has hundreds (or even thousands) of cells, but only a few are visible on screen at a time, UIKit provides a mechanism for reusing cells as they scroll offscreen and new cells scroll into view. And although UIKit provides such a mechanism, the API is somewhat lacking. And it certainly isn’t very swifty.


Dukkert 🏊 for iOS

less than 1 minute read

I just released a small hobby project to the App Store. It won’t make me rich, but its nice to start on a fresh project and try new stuff. Now that I’m a consultant, I need to keep my tools sharp, and there’s a lot of tech I’ve been wanting to try for some time. The app is written in 100% swift, using promises, value types were possible, etc. It has a thin backend written in node.js that runs on Heroku. Check it out!

Protocol ‘SequenceType’ can only be used as a generic constraint …

9 minute read

In Swift, a protocol can have an associated type, which is kinda like generics, except it isn’t. This is most often apparent when trying to use it as such. You’ve probably seen the compiler complain: Protocol 'SequenceType' can only be used as a generic constraint. In this post we explore why, and how to solve it.

less than 1 minute read

After five years in Telenor, the last two and a half in, I have finally decided I needed new challenges. It wasn’t an easy decision, but it was time. Five years in the same company feels like an eternity. Starting tomorrow, I will now work for a small consultancy. I’m excited to get started. Hopefully, I’ll be working on many more diverse projects.

How to avoid implicit retain cycles when using function references

8 minute read

One very nice thing about Swift is that functions are first-class values. They can be assigned to variables, curried, and you can pass them as arguments: If a function takes a closure as a parameter, you can pass a reference to a function in place of an in-line closure, as long as the types match. We may think of functions as just special kinds of closures with a name. But beware! Therein lies dragons.

App Transport Security in debug builds.

1 minute read

Since iOS 9, Apple has enforced best practices in the secure connections between your app and its back end, by adding something called “App Transport Security”, or “ATS” for short. ATS is on by default, and prevents accidental disclosure and provides secure default behavior by mandating that a network connection is over HTTPS, and by limiting the supported ciphers to a subset that is known to be secure, notably TLS 1.2 and so-called forward secrecy.