Learning Time : 40min
My Github : Bucket List Source Code
Codable
Structs for JSON ResponseResult
, Query
, and Page
structs conforming to Codable
to represent the JSON response from Wikipedia.struct Result: Codable {
let query: Query
}
struct Query: Codable {
let pages: [Int: Page]
}
struct Page: Codable {
let pageid: Int
let title: String
let terms: [String: [String]]?
}
enum LoadingState
to represent different loading states: .loading
, .loaded
, and .failed
.