What a wonderful tutorial, but there is a tiny mistake.
Above the sentence, “extension RestaurantListViewController: UITableViewDelegate” ,RestaurantDetailsViewController.swift should be RestaurantListViewController.swift
TL;DR: You should instantiate the decoder inside configuration closure instead of capturing an instance. Otherwise you’re calling for trouble.
Long version: Siesta’s transformer pipeline is dispatched asynchronously on background queue, and there are no guarantees of serial execution for transformers (unlike request hooks for example, which always run on the main queue). If you use a captured instance, you’re effectively sharing it between all invocations of response transformer for this partucular url, which can occur simultaneously. JSONDecoder is declared as class, meaning that it has a state which can be mutated during the decoding. Therefore we cannot blindly assume that it has some thread safety built in (even if it actually does), unless the class reference explicitly states this (it does not).
P.S. Strictly speaking, business-logic of the tutorial app does not allow two requests to happen simultaneously. But often it can be not that trivial or even not desirable to implement and maintain such guarantees in real-world app. It’s much simpler and safer to just instantiate the decoder at call site, and it’s cheap.