Created
April 8, 2018 12:40
-
-
Save rtking1993/67337dc066295f38c069240154e57fac to your computer and use it in GitHub Desktop.
Article model struct with Decodable protocol
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
// MARK: Frameworks | |
import Foundation | |
// MARK: Article | |
struct Articles: Decodable { | |
let count: Int | |
let results: [Article] | |
enum CodingKeys: CodingKey, String { | |
case count = "num_results" | |
case results = "results" | |
} | |
} | |
// MARK: Article | |
struct Article: Decodable { | |
let articleId: Int | |
let title: String | |
let url: URL | |
enum CodingKeys: CodingKey, String { | |
case articleId = "id" | |
case title = "title" | |
case url = "url" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment