Last active
October 14, 2020 04:37
-
-
Save kmuralidharan91/e4ddfabb72c6f1e573e2cc87c703ca4a 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
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