Category Archives: Swift

Top 100 Albums app – my approach to a code exercise

The completed project

I recently completed the development of an iOS app as a code exercise.   The goal was to display the top 100 albums across all genres using the Apple RSS generator.    You can find the TopAlbums project on GitHub.  The project description contains an animated GIF of the finished product, along with the detailed set of requirements.

What I wanted to do in this post is review my thought process in developing the app, along with any intricacies I came across.

Continue reading

Building an iOS app around the Unsplash API

Unsplash API

I enjoy discovering new APIs to experiment with.  In this case I came across Unsplash which is a source of high resolution images which are free to use.  The developer API is well documented and it is a simple process to register an app to obtain an API key.

To skip ahead and see what I built using this API, see my Unsplash demo app on GitHub.

An opportunity to build an iOS app

An Image API service provides a nice basis for building an iOS app.   It lends itself to working with table views, collection views, storage and many other iOS features.  The following screenshots show what I was able to achieve.

Continue reading

AppDeveloperKit-String: A Swift library for subscripting, regular expression matching and substitutions

String shortcomings

I really enjoy programming in Swift, but I’ve always been bothered a bit by what I perceived as a couple of shortcomings related to the String class.


There is no support for subscripting a String.

Try the following in a Playground and you’ll get an error:

 let str = "Hello"

 str[1]   // 'subscript' is unavailable: cannot subscript String with an Int
 str[1..<3] // 'subscript' is unavailable: cannot subscript String with an integer range

You can find a mention of this restriction in some source code comments.

Continue reading

Solving a HackerRank algorithm problem – Matrix Layer Rotation

Matrix Layer Rotation

I enjoy solving interesting HackerRank algorithm problems.  I came across one recently called Matrix Layer Rotation – appropriately labeled “hard” by the author.

I posted my solution as a playground on GitHub.

The problem is to print out a rotated representation of a m x n  matrix given the parameters:

m – number of rows
n – number of columns
r – number of rotations

Looking at the constraints

2 <= m, n <= 300
1 <= r <= 10^^9
min(m,n) % 2 = 0

Continue reading

Leave Swift Error Propagation Enabled

A harmless Database update

I was debugging a Swift Mac app that I’m developing that uses Realm for a database.  The version of RealmSwift I was currently using was 2.10.0 as specified in my Podfile.

I opened Realm Browser to inspect a record in my database.   Having been recently updated to version 3.0.1, it alerted me that my database was using an older file format and offered to upgrade it.   I accepted without thinking much of it.

An unexpected error

Continue reading