Skip to content

Instantly share code, notes, and snippets.

@Pasanpr Pasanpr/Class.swift Secret
Created Mar 28, 2018

What would you like to do?
Starter Code for S4:V3 - Decoding to a Class
import Foundation
let json = """
"id": "ABCD",
"title": "Some Title"
""".data(using: .utf8)!
class Media: Codable {
let id: String
let title: String
let decoder = JSONDecoder()
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let media = try! decoder.decode(Media.self, from: json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.