Skip to content

Instantly share code, notes, and snippets.

@ricardopereira
Created February 9, 2016 12:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricardopereira/c59aa8f0ebd834a0aa27 to your computer and use it in GitHub Desktop.
Save ricardopereira/c59aa8f0ebd834a0aa27 to your computer and use it in GitHub Desktop.
import UIKit
import XCPlayground
let items = ["One", "Two"]
let notificationsVC = UITableViewController()
class NotificationsDataSource: NSObject, UITableViewDataSource {
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
return UITableViewCell()
}
}
class NotificationsTableDelegate: NSObject, UITableViewDelegate {
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
cell.textLabel?.text = items[indexPath.row]
}
}
let dataSource = NotificationsDataSource()
let tableDelegate = NotificationsTableDelegate()
notificationsVC.tableView.dataSource = dataSource
notificationsVC.tableView.delegate = tableDelegate
XCPlaygroundPage.currentPage.liveView = notificationsVC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment