Using AsyncDisplayKit for a smooth UI

27. March 2016 blog 0

So we’re building this awesome new app but after spending time revamping our result list we found out it just wasn’t performing well enough. We were using a UICollectionView but calculating the position of all the elements in each item in the collection was just too slow. We found out about AsyncDisplayKit (ASDK).

ASDK offers an abstraction over UIView and CALayer that allows you to perform the calculation of frames to background threads instead of the main thread. This dramatically speeds up the rendering of complex UI’s. After implementing ASDK our list is now super smooth and doesn’t lag at all.

Here are some things to take into consideration when implementing ASDK:

  • Actively maintained. The ASDK library is under very active development. It was originally built to power facebook’s Paper app and it seems mature enough to use in live projects.
  • Objective-C, not Swift. ASDK is built in Objective-C. It’s not complicated to use an Objective-C library in a Swift project but if you’re a Swift purist you might not want to do this.
  • Nodes, not Views. ASDK uses a concept called “Nodes”. Nodes are essentially UI elements and can be considered an abstraction of a View or a Layer. You use these nodes to define your UI and ASDK will asynchronously create views or layers to represent this UI.
  • LayoutSpec, not Auto Layout. Because ASDK uses Nodes to define UI elements, it doesn’t support things like Auto Layout or Constraints. Instead, ASDK uses something called a “LayoutSpec”. There are a number of different ways to layout nodes. To get an idea of the kind of layout you can define, have a look at the *LayoutSpec Class References.


Example node

Here’s an example of a very simple custom ASDK node. All this node does is display a label (called an “ASTextNode” within the bounds of the node. The LayoutSpec for this node also defines an inset of 10 pixels all around the text node.


Other resources

Blog, The Origin Story

29. February 2016 blog 0

Hi there. You might know me and I might now know you. But there’s a chance that if you’ve reached this page you are somewhat interested in iOS development, Swift development or both. Let me introduce myself first.

I’m Roel, a 30-something iOS developer from The Netherlands. I work at funda, the largest real estate website in our country. Together with about a 100 colleagues (half of those are developers) we develop and maintain a website containing most of the for-sale and for-rent properties in The Netherlands.

Besides a website, we also have iOS, Android and Windows Phone apps. We have a dedicated “mobile” team that maintains these apps and an API that supports it. This team is currently on a mission to rebuild our apps from the ground up with the latest technology, making use of the lessons we learned the last few years.

This blog will be a place for me to share some of the choices we make during this rebuild process and some of the technical challenges we face. These can range from simple snippets of code to posts on architecture and iOS development philosophy.

Let’s get going!