Skip to content

Instantly share code, notes, and snippets.

@terrybu
Created July 31, 2015 00:39
Show Gist options
  • Save terrybu/3d42e33aa8a90c1189f7 to your computer and use it in GitHub Desktop.
Save terrybu/3d42e33aa8a90c1189f7 to your computer and use it in GitHub Desktop.
Boilerplate cellForRowAtIndexPath with reuse identifier - Swift
private let cellReuseIdentifier: String = "yourCellReuseIdentifier"
//
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell : UITableViewCell? = tableView.dequeueReusableCellWithIdentifier(cellReuseIdentifier) as? UITableViewCell
if (cell == nil) {
cell = UITableViewCell(style:.Default, reuseIdentifier:cellReuseIdentifier)
}
cell!.textLabel!.text = "Hello World"
return cell!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment