Create a gist now

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() {
super.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
self.view.addSubview(tableView)
}
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