Skip to content

Instantly share code, notes, and snippets.

@hmlongco
Created August 4, 2022 20:00
Show Gist options
  • Save hmlongco/6eb0408b4ea580f06556010a32a09755 to your computer and use it in GitHub Desktop.
Save hmlongco/6eb0408b4ea580f06556010a32a09755 to your computer and use it in GitHub Desktop.
WrappedCodable.swift
struct ToDoStore: Codable {
let userId: Int
let id: Int
var title: String
var completed: Bool
}
struct ToDo {
private var toDo: ToDoStore
public init(toDo: ToDoStore) {
self.toDo = toDo
}
var id: Int { toDo.id }
var userId: Int { toDo.userId }
var title: String { toDo.title }
var isCompleted: Bool {
get { toDo.completed }
mutating set { toDo.completed = newValue }
}
var isSelected: Bool = false
var isEnabled: Bool = false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment