Apr 25, 2016

Updating an Objective-C library for Swift

Recently I updated an Objective-C library for improved Swift interoperability. The Objective-C library hadn’t been touched for a while to the extent that it still used manually memory management rather than ARC. Converting a pre-ARC library added additional challenges.

All the changes made are contained in this pull request. I also added a Travis CI build for the library.

More »

Apr 20, 2016

Avoiding Swift's [Any] by using functional patterns

In my previous post: “Unexpected behaviour with Swift’s [Any]”, I declared a nested array of integers as:

let a : [Any] = [1,2,[3],[4,[5,6]],[[7]], 8]

Using Any feels like a code smell; by using Any I’m effectively saying, “ignore all the type-checking the compiler performs, instead I’ll rely on my own knowledge of the types”. Experience shows I am not as knowledgable as the compiler, especially after some time has elapsed and I’m trying to add a new feature…

More »

Apr 19, 2016

Unexpected behaviour with Swift's [Any]

Any idea why the following code is generating a runtime exception?:

Adding an explicit type declaration solves the problem:

But why?

More »

Mar 27, 2016

Remote software development work

When I moved from London to Devon, I was fortunate that the company for whom I was then contracting (TLC), valued my work sufficiently to extend my contract and allowed me to work remotely. I worked four days a week in Devon and travelled to London one day a week to catch-up with the team I was managing. This arrangement worked well both for me and the company. I could spend more time with my young family and enjoy the beautiful surroundings of my new location, while TLC kept a talented developer they otherwise might have lost. More importantly, I became far more productive away from the day-to-day distractions of the main office as well as working hard to ensure that I remained closely in-touch with the rest of the team; I felt the onus was on me to show the arrangement not only would work, but would have far more upside for TLC than downside.

More »

Mar 7, 2016

Type erasure with AnyError

NADocumentPicker returns a Future<T, E: ErrorType> with the type:

Future<NSURL, AnyError>

What is AnyError in the above code? AnyError provides a unified concrete error type for a Future . A unified error type is necessary when composing futures with flatMap so, if one of the futures fails, the error can be propagated through the compositional chain.

More »