I have a custom view controller in my storyboard, not hooked up to anything but identified as "MyCustomViewController". For prototyping purposes I have a single NSTextField that says "Got Here!" inside the view that's inside the view controller. I'm trying to get this to be rendered as the row in my table view. In the code below, if 'simple' is true, I get an NSTextField rendered that says "Got Here!", with viewForTableColum and objectForTableColumn called. If 'simple' is false, I get a blank table view and only viewForTableColumn is called. I am successfully loading the custom view controller, though. I figure I'm missing something simple, but a day's worth of looking at other people's examples hasn't helped so far. :/ Worth noting that I also experimented with creating a separate nib with just a view in it, no view controller, but that ended up being a deep rat hole that I couldn't escape (I couldn't get it initialized properly).
TIA for any help you can provide!
class ViewController: NSViewController, NSTableViewDataSource, NSTableViewDelegate {
let simple = true
@IBOutlet var tableView: NSTableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.setDataSource(self)
tableView.setDelegate(self)
}
func numberOfRowsInTableView(tview: NSTableView) -> Int {
return 1
}
func tableView(tview: NSTableView, objectValueForTableColumn col: NSTableColumn?, row: Int) -> AnyObject? {
println("tableview objectValueForTableColumn called")
return "Got Here!"
}
func tableView(tview: NSTableView, viewForTableColumn col: NSTableColumn?, row: Int) -> NSView? {
var result: NSView?
println("tableview viewForTableColumn called")
if (simple) {
result = NSTextField()
}
else {
if let customVC = storyboard?.instantiateControllerWithIdentifier("MyCustomViewController") as? NSViewController {
result = customVC.view
}
else {
println("no storyboard")
}
}
return result
}
}