Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A dumb Swift UIViewController with UITableView
import UIKit
class DumbViewController: UIViewController, UITableViewDataSource {
var items: [Int] = [Int]()
override func viewDidLoad() {
self.view.backgroundColor = UIColor.whiteColor()
(0...100).map({ items += value })
let tableView: UITableView = UITableView(frame: self.view.frame)
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
tableView.dataSource = self
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
return items.count
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
cell.textLabel.text = "\(items[indexPath.row])"
return cell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.