Skip to content

Instantly share code, notes, and snippets.

@Kdan
Last active April 10, 2018 19:00
Show Gist options
  • Save Kdan/9d78490d35d29c480dd41eca90b28531 to your computer and use it in GitHub Desktop.
Save Kdan/9d78490d35d29c480dd41eca90b28531 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([Pet].self, from: data))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment