All posts filed under: Dev

Reversing a Swift String in Place

Dev

One of the interview questions at my old job we’d ask sometimes was to reverse a string in place; usually using C or Java. After conducting an interview one time, I decided to rewrite it in Swift. Here’s what I came up with: func reverse(string: inout String) { var i = string.startIndex var j = string.index(before: string.endIndex) while i < j { let first = string[i] let second = string[j] string.remove(at: i) string.insert(second, at: i) […]

Equatable Swift (NS)Objects

Dev

How to implement equality with different kinds of Swift objects was pretty obvious once I read the documentation, but the errors I got at first were not entirely clear. If you want to show equality between two objects in Swift, you have to do something different depending on if they subclass NSObject or not. In the case of an NSObject subclass, you would override -isEqual:: override func isEqual(to object: Any?) -> Bool { guard let […]

RevenueCat Makes iOS Subscriptions Easy

Dev

My friend Jacob Eiting just released a new service to make adding subscription payments into iOS apps super easy. I checked out the API and it looks great. RevenueCat is the best way to implement subscriptions in your mobile app. We handle all the complicated parts so you can get back to building. You can check out RevenueCat here.

Counting Bits in an Integer

Dev

During a tech screen I was given the task of writing a function to count the number of bits in an integer given. I thought I’d share what I came up with. #include <stdio.h> int count_bits(int i) { int bit_count = 0; int comparator = 0x1; for (int x = 0; x < sizeof(int) * 8; x++) { if (comparator & i) { bit_count++; } comparitor <<= 1; } return bit_count; } int main(int argc, […]

Putting Code on Dropbox

Dev

On the latest episode of Under the Radar, David mentioned that he stores all of his code in Dropbox, rather than pushing and pulling to a Git repo to sync between his machines. Of course, he’s not an animal, so he also uses Git, just not for syncing between his personal machines. I’ve never done this but once he said it, I was pretty much convinced and moved all of my code to a folder […]

If Object-Oriented Programming Were Announced Today

Dev

Graham Lee has a post titled If Object-Oriented Programming were announced today: Here’s an idea: the current backlash against OOP is actually because people aren’t doing OOP, they’re doing whatever they were doing before OOP. But they’re calling it OOP, because the people who were promoting OOP wanted them to believe that they were already doing OOP. Basically, Graham argues that a lot of the “newer” paradigms are just OOP by a different name, and […]

My New Podcast: The Run Loop

Apps / Design / Dev

The first episode of my new podcast, The Run Loop, is now available in iTunes, Overcast, and wherever else great podcasts are found. You can also listen and subscribe on the shows website. The Run Loop will be a weekly discussion about making iOS and Mac apps with great designers and developers. In this episode I talk to my friend Samuel Goodwin about how he got started, peer mentorship, our trip to Japan, and more. […]

The CocoaPods App

Dev

Managing third party code on iOS has always been a pain. In the past 9 years or so I’ve done everything from dragging source directly into projects, to Git submodules, to CocoaPods, to Carthage, to Git submodules again. Right now I’m using CocoaPods. I’ve had three problems with CocoaPods from the beginning: It messes with my Xcode project files. It stops working for me all the time. I don’t want to mess around with Ruby […]

Creating StoryWorth for iOS 1.0

Apps / Design / Dev

I’m really excited to announce that a new app I’ve been working on for several months has come out today. The app is called StoryWorth, and you can download it now. It’s a companion to the website of the company I work for. StoryWorth lets you collect and share (with recipients you choose) your family stories. To get started, you invite a storyteller (mom, dad, grandma, etc), and then we start sending them questions. They […]