Skip to content

Instantly share code, notes, and snippets.

@kmuralidharan91
Last active October 14, 2020 04:37
Show Gist options
  • Save kmuralidharan91/e4ddfabb72c6f1e573e2cc87c703ca4a to your computer and use it in GitHub Desktop.
Save kmuralidharan91/e4ddfabb72c6f1e573e2cc87c703ca4a to your computer and use it in GitHub Desktop.
import UIKit
final class HomeTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.register(CustomTableViewCell.self,
forCellReuseIdentifier: "CustomTableViewCell")
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return Constants.fruits.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(
withIdentifier: "CustomTableViewCell") as? CustomTableViewCell
else { return UITableViewCell() }
cell.setUI(with: indexPath.row)
return cell
}
}
enum Constants {
static let fruits = ["apple", "avacoda", "cherry", "coconut", "dragon" ,"grapes",
"guava", "kiwi", "melom", "orange", "peach", "salak", "straw"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment