Search code examples
swiftxcodemacosinterface-builderxcode-storyboard

Xcode build not showing Table Cell


In the interface builder I see: enter image description here

but in the built running app, I don't see my red text cell: enter image description here

here's my Main.storyboard TableView in the Interface Build side panel: enter image description here

it's just a normal table view dragged out from the UI Objects menu onto the Storyboard.


Solution

  • You might be missing the configuration required in NSTableViewDataSource and NSTableViewDelegate methods as follows. You need to set the dataSource and delegate of the NSTableView you just drag and dropped and implement numberOfRowsInTableView method for the class that conforms to these protocols.

    func numberOfRowsInTableView(tableView: NSTableView) -> Int {
        return 1
    }
    

    Note: It would be best if you go through this tutorial which I found helpful for Cocoa development with NSTableView.