Created
April 20, 2021 19:42
-
-
Save mhijack/da2cae7d304bef7e4c9c0719d7c6ae60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
switch data.count == 0 { | |
case true: | |
return 1 | |
case false: | |
return data.count | |
} | |
} | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
switch data.count == 0 { | |
case true: | |
/// No content | |
guard let cell = tableView.dequeueReusableCell(withIdentifier: "empty-cell-id", for: indexPath) as? EmptyTableViewCell | |
else { return EmptyTableViewCell() } | |
let noResultsView = NoResultsView() | |
noResultsView.setContent() | |
cell.setup(view: noResultsView) | |
return cell | |
case false: | |
/// User cell | |
guard let cell = tableView.dequeueReusableCell(withIdentifier: "cell-id", for: indexPath) as? DataTableViewCell | |
else { return DataTableViewCell() } | |
cell.setContent(data: data[indexPath.row]) | |
return cell | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment