Last active
May 27, 2016 15:42
-
-
Save welbesw/993708871447e73f91063d1f0e63458a 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
// UITableView data source delegate methods | |
// These are the methods that UITableView calls on the controller to | |
// setup the table view with the number of items and a reusable cell | |
override func numberOfSectionsInTableView(tableView: UITableView) -> Int { | |
// return the number of sections | |
return 1 | |
} | |
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
// return the number of rows - number of items in an array | |
return items.count | |
} | |
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { | |
// Dequeue a cell from the UITableView. This method will always return a cell - creating one if needed | |
let cell = tableView.dequeueReusableCellWithIdentifier("stringItemCell", forIndexPath: indexPath) | |
// Get the item from the array for this index | |
let stringItem = items[indexPath.row] | |
// Update the cell. The views should be updated with the appropriate items each time this is called | |
// since cells are reused and therefore will have data from a different row item if reused and not updated. | |
cell.textLabel?.text = stringItem | |
return cell | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment