Created
February 9, 2016 12:00
-
-
Save ricardopereira/c59aa8f0ebd834a0aa27 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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