Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
You can’t perform that action at this time.