Skip to content

Instantly share code, notes, and snippets.

@nithingwl
Created December 1, 2017 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nithingwl/2d6d8cca246fccf89662ec448bbc2010 to your computer and use it in GitHub Desktop.
Save nithingwl/2d6d8cca246fccf89662ec448bbc2010 to your computer and use it in GitHub Desktop.
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