Skip to content

Instantly share code, notes, and snippets.

@Kdan
Last active April 10, 2018 19:00
Show Gist options
  • Save Kdan/87f1de0527420706d99be9a5730beb6c to your computer and use it in GitHub Desktop.
Save Kdan/87f1de0527420706d99be9a5730beb6c to your computer and use it in GitHub Desktop.
class Person: Codable {
let name: String
/// Retrieve the pets of the Person.
func getPets(completion: ([Pet]) -> Void) throws {
// Networking request omitted for simplicity.
let data = responseData
completion(try JSONDecoder().decode([ClassWrapper<PetFamily, Pet>].self, from: data).compactMap { $0.object })
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment