tvOS: Dynamic TopShelf Based on Remote JSON

How to build a sectioned top shelf with Alamofire, SwiftyJSON and love.

I’m currently working on an app for the new Apple TV. I was trying to build a sectioned TopShelf with dynamic content. During the first two betas I wasn’t having much success. In Xcode 7.1 beta 3 it finally started working for me. I’m not sure if it had to do with the beta 3 or incorporating Semaphore into it. Anyway, here is the sectioned TopShelf I am building:


As you can see it has a variety of different sizes and all of that is controlled in the remote JSON file that you will ping through Alamofire (check the tvOS branch). I’ve included my code below if you want to check it out. Also reviewing my JSON file should explain most of it as well.


appletv-topshelf.json ServiceProvider.swift

Setup Extension

Your extension ends up being one swift file: ServiceProvider.swift If you want help getting to that point, this video helped me get the Top Shelf Extension setup.

Here is my current ServiceProvider.swift: