Skip to content

Instantly share code, notes, and snippets.

@sebastianbachmann
Forked from jquave/SwiftTable
Created September 10, 2018 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastianbachmann/e4fb6293a6e0d3ad60b84891b2e2f90b to your computer and use it in GitHub Desktop.
Save sebastianbachmann/e4fb6293a6e0d3ad60b84891b2e2f90b to your computer and use it in GitHub Desktop.
Example code for Table View in Swift
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
return 10
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "MyTestCell")
cell.text = "Row #\(indexPath.row)"
cell.detailTextLabel.text = "Subtitle #\(indexPath.row)"
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment