Ben Dodson

Freelance iOS, Apple Watch, and Apple TV Developer

Since, an NSDate Extension in Swift

I’ve just committed a very simple NSDate extension that gives you a human readable version of the time difference between the date and now (i.e. “2 hours ago”, “just now”, or “last week”). I needed this functionality in a project I’m currently working on but existing solutions I found were all Objective-C and fairly complex. I try not to add any complex 3rd party dependencies when I don’t have to (especially as I don’t want an Objective-C bridging header) so I built this in a few minutes to give me the basic functionality I required. You can check it out on GitHub.

In many ways, this sums up how I feel about some development today. Many developers will either embed a 3rd party solution without thinking about it (giving you licensing and support issues in the future) or they’ll spend hours crafting the perfect solution that will give you to-the-second precision with unit tests and a whole host of other stuff you probably don’t need1. Sometimes you just need the simplest thing that works so you can move onto more important things.

  1. An oft-mentioned story about Steve Jobs regards how his father would spend as much time making the back of a cabinet (which you’d never see) look as good as the front as a sign of good craftsmanship. This has its place but its important to remember that “real artists ship”; I’d rather have a project that is live and performing than spend hours crafting the “perfect” piece of code. ↩︎

Adding Exercise Data To Activity » « Using an SSD with the Xbox One