Skip to content

Instantly share code, notes, and snippets.

@vikage
Created July 24, 2021 09:29
Show Gist options
  • Save vikage/5c494bb0ea47a24405831a05ef500215 to your computer and use it in GitHub Desktop.
Save vikage/5c494bb0ea47a24405831a05ef500215 to your computer and use it in GitHub Desktop.
class Project {
var name: String
var createdDate: Date
init(name: String, createdDate: Date = Date()) {
self.name = name
self.createdDate = createdDate
}
}
protocol ProjectDao {
func addProject(_ project: Project)
}
class ProjectDaoImpl: ProjectDao {
func addProject(_ project: Project) {
// Placeholder: Add object to realm
}
}
class ProjectManager {
var dao: ProjectDao
init(dao: ProjectDao) {
self.dao = dao
}
func addProject(_ project: Project) {
dao.addProject(project)
// Do anything else here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment