Skip to content

Instantly share code, notes, and snippets.

@mhijack
Last active April 21, 2021 23:21
Show Gist options
  • Save mhijack/c2d62d001ee06da012b274a11b42801c to your computer and use it in GitHub Desktop.
Save mhijack/c2d62d001ee06da012b274a11b42801c to your computer and use it in GitHub Desktop.
class EmptyTableView: UITableView {
var emptyDataSource: EmptyTableViewDataSource
var emptyTableViewDelegate: EmptyTableViewDelegate?
var normalDataSource: UITableViewDataSource
var normalTableViewDelegate: UITableViewDelegate?
/// If we don't pass in empty and normal data source, this table view can be used as a regular table view.
init(emptyDataSource: EmptyTableViewDataSource,
normalDataSource: UITableViewDataSource,
emptyTableViewDelegate: EmptyTableViewDelegate? = nil,
normalTableViewDelegate: UITableViewDelegate? = nil) {
self.emptyDataSource = emptyDataSource
self.normalDataSource = normalDataSource
self.emptyTableViewDelegate = emptyTableViewDelegate
self.normalTableViewDelegate = normalTableViewDelegate
super.init(frame: .zero, style: .plain)
dataSource = normalDataSource
delegate = normalTableViewDelegate
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment