Created
July 13, 2016 21:23
-
-
Save bizz84/50ef51ecd4b753e6514966af6ad2f846 to your computer and use it in GitHub Desktop.
This file contains 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
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