Skip to content

Instantly share code, notes, and snippets.

@rtking1993
Created April 8, 2018 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtking1993/67337dc066295f38c069240154e57fac to your computer and use it in GitHub Desktop.
Save rtking1993/67337dc066295f38c069240154e57fac to your computer and use it in GitHub Desktop.
Article model struct with Decodable protocol
// 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