Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Created July 2, 2020 14:17
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 stevencurtis/c14f619bc3975b425d6606233db1de4e to your computer and use it in GitHub Desktop.
Save stevencurtis/c14f619bc3975b425d6606233db1de4e to your computer and use it in GitHub Desktop.
uikitversion
import UIKit
import PlaygroundSupport
final class MyViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
let strings = ["1", "2", "3", "4", "5"]
var tableView : UITableView!
override func loadView() {
self.tableView = UITableView()
self.view = tableView
tableView.register(UITableViewCell.self, forCellReuseIdentifier: String(describing: UITableViewCell.self))
self.tableView.delegate = self
self.tableView.dataSource = self
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return strings.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: UITableViewCell.self))
cell?.textLabel?.text = strings[indexPath.row]
return cell!
}
}
// set the view and indefiniteexecution
PlaygroundPage.current.needsIndefiniteExecution = true
PlaygroundPage.current.liveView = MyViewController()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment