Skip to content

Instantly share code, notes, and snippets.

@tsif
Last active July 13, 2017 07:39
Show Gist options
  • Save tsif/328c9d4a43a2e787104803cbd837b6cc to your computer and use it in GitHub Desktop.
Save tsif/328c9d4a43a2e787104803cbd837b6cc to your computer and use it in GitHub Desktop.
Boilerplate for Swift UITableView
/*
* TableViewcontroller.swift
*/
import UIKit
class TableViewcontroller: UIViewController, UITableViewDataSource, UITableViewDelegate {
// MARK: - PROPERTIES
@IBOutlet weak var tableView : UITableView!
// MARK: - LIFECYCLE
override func viewDidLoad() {
super.viewDidLoad()
setupView();
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
// MARK: - SETUP
func setupView() {
let nib = UINib.init(nibName: "", bundle: nil);
self.tableView.register(nib, forCellReuseIdentifier: "")
}
// MARK: - NAVIGATION
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
}
// MARK: - TABLEVIEW
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 0.0;
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 0
}
func numberOfSections(in tableView: UITableView) -> Int {
return 0
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "")
return cell;
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: false)
}
// MARK: - CLEANUP CREW
deinit {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment