Created
August 17, 2020 07:50
-
-
Save alexnikol/6849caec6c33ccf8bb8718cfe8ae7ae1 to your computer and use it in GitHub Desktop.
Default Pagination Realization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Pagination: Decodable { | |
var cars: [Car] | |
var currentPage: Int | |
var totalPages: Int | |
enum ResultCodingKeys: String, CodingKey { | |
case cars, currentPage, totalPages | |
} | |
required init(from decoder: Decoder) throws { | |
let objectsContainer = try decoder.container(keyedBy: ResultCodingKeys.self) | |
currentPage = try objectsContainer.decode(Int.self, forKey: .currentPage) | |
totalPages = try objectsContainer.decode(Int.self, forKey: .totalPages) | |
cars = try objectsContainer.decode([Car].self, forKey: .cars) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment