Created
July 2, 2020 14:17
-
-
Save stevencurtis/c14f619bc3975b425d6606233db1de4e to your computer and use it in GitHub Desktop.
uikitversion
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
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