Decoding Heterogeneous Collections in Swift

The problem of decoding Swift types from an outside data source, such as JSON, has been mostly solved. Since Swift’s release we’ve seen more than a dozen popular JSON mapping libraries pop up.

However, most of the libraries I’ve seen so far deal with decoding individual types, not entire collections of heterogeneous types.

Read More...

Compile Time vs. Run Time Type Checking in Swift

At some point, when learning how to use Swift’s type system, it is important to understand that Swift (like many other languages) has two different forms of type checking: static and dynamic. Today I want to briefly discuss the difference between them and why headaches might arise when we try to combine them.

Read More...

Introducing ReSwift

For the last two months I have been actively working on Swift Flow with the goal of bringing the ideas of the Flux and Redux libraries to Swift developers.

Read More...

Swift Error Handling and Objective-C Interop in Depth

For the impatient reader:

TL;DR

  • The ErrorType protocol has hidden requirements that are automatically fullfilled if you use an enum to implement the protocol
  • Objective-C methods can only be translated to Swift’s error handling mechanism if they return Objective-C objects or boolean values
  • Swift will invoke the catch block if the Objective-C method returns nil/false, independent of whether an NSError was produced or not
  • If an Objective-C method produces an NSError and returns a value the catch blocks is not invoked and the error cannot be retrieved
  • GitHub project with examples

Read More...