Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class MenuViewController:UIViewController, UITableViewDataSource,UITableViewDelegate{
@IBOutlet weak var tableView: UITableView!
var menuItems = [String]()
override func viewDidLoad() {
super.viewDidLoad()
menuItems = ["Dashboard", "Settings", "Notifications"]
tableView.reloadData()
}
//MARK: - Table view datasource and delegates
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return menuItems.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier:MenuTableViewCell.reuseIdentifier,
for: indexPath) as! MenuTableViewCell
let menu = menuItems[indexPath.row]
cell.lblMenu.text = menu
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment