Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bizz84/50ef51ecd4b753e6514966af6ad2f846 to your computer and use it in GitHub Desktop.
Save bizz84/50ef51ecd4b753e6514966af6ad2f846 to your computer and use it in GitHub Desktop.
class ViewController: UIViewController, UITableViewDataSource {
@IBOutlet var tableView: UITableView!
var dataSource: [DataItem]
// MARK: UITableViewDataSource
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return dataSource.count
}
func tableView(tableView: UITableView,
cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
return tableView.dequeueReusableCellWithIdentifier("cellID")!
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let cell = sender as? UITableViewCell,
let indexPath = tableView.indexPathForCell(cell) {
let item = dataSource[indexPath.row]
segue.destinationViewController.title = item.title
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment