Swift Copy-on-Write PSA: Mutating Dictionary Entries

Yesterday, the ever-insightful Tim Vermeulen pointed out a significant performance bug in some of the iOS-Developers production code. Swift's copy-on-write system usually helps efficiency by delaying the copying of structs until it's actually needed. However, as shown here, you can run into some pitfalls if you aren't vigilant of what's going on under the hood…. Continue reading

Strange Behavior with Breakpoints in Swift

While hunting down a bug in Camille (the iOS-Developers Slack bot), I ran across some interesting and unexpected behavior in the Swift debugger. Normally when you place a breakpoint on a line, you expect that line (and all those after it) to not be evaluated yet. It seems that in certain cases, this is not… Continue reading

Who’s Your Project Manager?

Every engineering team has a project manager; some have more than one. In fact, the teams who claim to have no project managers actually have the most: everyone on that team is a project manager. This isn't necessarily a bad thing. When your company is 5-10 people and you all work next to each other,… Continue reading

How Code Echoes Design

The more software I have created, the more I have considered myself "design-minded", especially with regards to user experience. It's not that I am designing software myself, but rather that I observe and place more value on design than I used to. Coincidentally, I've noticed some changes in my habits as a developer. I spend… Continue reading

Bonus Round – Spanning Sequences in Swift 3.1

Last week, some of you may have noticed that our groupByUser function used the same "test" closure twice, once for prefix(while:) and once for drop(while:). It kind of seems like these two are doing the same thing, right? We are splitting the array at a certain point; one time we want the subsequence before the… Continue reading

Swift 3.1 – prefix(while:) and drop(while:)

Just a hot minute too late for Swift 3.0, these two super-useful sequence methods have been implemented for Swift 3.1, and can be used right now on the development branch. Let's take a look at what we can do with these functions. Suppose you have a list of messages in the chat section of your… Continue reading

Swift and Objective-C: An Ouroboros

For the release of Swift 3, I have created an ouroboros program using Swift, and that old language dear to my heart, Objective-C. This is a program that is a type of quine: starting as a Swift program, running it will print out an Objective-C program. Running this resulting Objective-C program will print out the… Continue reading

Sneaky Reference Cycles in Swift Instance Methods

What if I told you the Swift compiler is adding strong reference cycles into your code without telling you, and laughing behind your back? Why, you might think I'm a conspiracy nut, tell your friends I'm a madman and run me out of town! Which is all well and good, but then you'll never find… Continue reading

Cow Path Conditionals

The roads of Boston are a knot of one-ways, unexpected curves, and no-left-turns. Local lore holds that they were once cow paths, and by the time road planning was needed the city decided to just use what was there. After all, they already connected all the important places. Sometimes writing code is like leading your… Continue reading

Algorithm Design Manual: Ramanujan Numbers

While reading The Algorithm Design Manual, I found a problem that seemed like a classic mathematical calculation, but had no solution in the wiki. After a decent amount of Googling, I found only two algorithms online: a O(n4) brute-force approach, and a O(n3) dynamic programming approach. For those reading the book after me, I'd like… Continue reading