Show TableView in Swift Playgrounds for iPad

Everything works fine except the last line where I try to show the tableView in live view does not work: PlaygroundPage.current.liveView = controller

I can’t figure out what I’m getting wrong?

  • UIImage masking problems iOS 7
  • Doing Undo and Redo with Cglayer Drawing
  • Scroll to top of UITableView by tapping status bar
  • Why use class only protocols in Swift?
  • Can't get a notification when connecting an external accessory to the 3.5 mm headphones jack
  • How to disable iOS System Sounds
  • import UIKit
    import PlaygroundSupport
    import Foundation
    class TableViewController: UITableViewController {
        let tableData = ["Matthew", "Mark", "Luke", "John"]
    override func viewDidLoad() {
        print("Hello Matt")
    override func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return tableData.count
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as UITableViewCell
        cell.textLabel?.text = tableData[indexPath.row]
        return cell
    let controller = TableViewController()
    PlaygroundPage.current.liveView = controller

    Solutions Collect From Internet About “Show TableView in Swift Playgrounds for iPad”

    I think you forgot to register the table view cell class in viewDidLoad()

    override func viewDidLoad() {
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")