At the try! Swift Conference in Tokyo, @purpleyay gave a mind-blowing talk on Type Erasure (full video and slides here). I’m honestly still trying to wrap my head around it, and especially the use-cases, but for now, I wanted to write down the example from the talk to keep in my mind and refer to later when it suddenly fits the problem I’m solving.

Read More »


Objective-C originates from the early 1980s, and while the language has evolved a lot over the years, it’s still no match for really modern languages like Swift. With Swift 3.0 on the horizon, it’s smart to write new apps in Swift. However at PSPDFKit, we are still firmly in the Objective-C world. We build and distribute a binary framework to render and edit PDF documents. Getting all the PDF details right is a complex problem. In addition to core PDF functionality, we also offer a lot of UI classes to help with typical use cases. This results in a code base that is around 600k lines — a mix of shared C++ code and Objective-C++ for UI and wrapped models. Our headers are entirely modern Objective-C annotated with generics and nullability to ensure everything works great with Swift. Even though we are currently still stuck in the Objective-C world, it is not all that grim! With some ingenuity one can leverage many of the benefits of Swift even in a code base like ours. Here we’ll list some of the approaches we use to bring the old and new world closer together.

Read More »


I guess this blog post is irrelevant for most App developers, as the performance optimisations, or rather pitfalls which I will discuss in this post are not that important in day to day App development. However if you are a nerd like me and curious about performance and Swift language, then you came to the right place.

Last year I stumbled upon FlatBuffer, a fast serialisation library developed at Google. I liked it so much that I decided to bring FlatBuffers to Swift. If you are curious about the details, here is a talk I delivered on this manner couple of months ago.

Read More »


The use of recursion can often lead to a cleaner implementation of your algorithms but when compared with implementations based on loops, recursive ones incur in the additional cost of allocating and managing a new stack frame for every method call performed, something that makes the recursive implementation slower and that can also quickly lead to stack exhaustion (aka stack overflow).

To avoid the risk of overflowing the stack, the recommended approach suggests to rewrite your algorithm employing tail recursion to leverage the tail call optimization that some compilers provide.

Read More »


So… The design team just asked you to make an animation sexier and you went pale. What did they mean? The situation then got more awkward as they started talking about key frames and animation curves.

Motion graphics applications offers a lot of flexibility and to a designer there may sometimes be an expectation that the same flexibility is found in Swift / Cocoa Touch. Of course we all know that Swift is awesome and everything is possible but let’s stick to the basics.

Read More »


Swift generics are a great tool when applied appropriately. They are immensely useful both in an object form, as generic parameter for class, enum or struct type, and in constraint form, as associatedtype and Self requirements in protocol. The standard library and many community libraries put generics to work for code reduction and simplification.

Read More »


I love animations. They make users happy, they can express more than just some static UI element.

Recently, a friend of mine, Rafael Ramos (@rakaramos), showed me a code that he wrote to create an animation that he saw in CreativeDash’s Dribbble. Check this out here.

I thought that it was very cool and decided to do the same because it is such a great opportunity to:

  • Practice Swift
  • Learn more about CoreAnimation
  • Create an open source UI component
  • Have fun! 😊

Read More »