Slide 37
Slide 37 text
https://github.com/tattn/Mergeable
struct APIResponse: Codable {
let id: Int
let title: String
let foo: String
}
struct APIResponse2: Codable {
let tags: [String]
}
struct Model: Codable, Mergeable {
let id: Int
let title: String
let tags: [String]
}
let response = APIResponse(id: 0, title: "ʹΌʔΜ", foo: "bar")
let response2 = APIResponse2(tags: ["swift", "ios", "macos"])
let model = try! Model.merge(response, response2)
XCTAssertEqual(model.id, response.id)
XCTAssertEqual(model.title, response.title)
XCTAssertEqual(model.tags, response2.tags)