I have a simple OutlineView and TreeController that I'm linking via Cocoa binding, and for some reason, the first column's cells do not populate with data, but still show their triangles. Any other column seems to work. I've reviewed the bindings inspector for hours now and can't find out what's wrong and/or missing.
Image of app missing data in first cell:
Node
class Node: NSObject {
@objc dynamic let id: String
@objc dynamic let value: Double
@objc dynamic var children: [Node]
init(_ id: String,
_ value: Double,
_ children: [Node] = []) {
self.id = id
self.value = value
self.children = children
}
@objc dynamic var isLeaf: Bool {
return children.isEmpty
}
@objc dynamic var childCount: Int {
return children.count
}
}
ViewController
import Cocoa
class ViewController: NSViewController {
@objc dynamic var transactions = [Transaction]()
@objc dynamic var nodes = [Node]()
@IBOutlet weak var outlineView: NSOutlineView!
@IBOutlet var treeController: NSTreeController!
override func viewDidLoad() {
super.viewDidLoad()
let nodeOne = Node("first", 1.0, [Node("subOne", 1.1), Node("subTwo", 1.2)])
let nodeTwo = Node("second", 2.0, [Node("subOne", 2.1), Node("subTwo", 2.2), Node("subThree", 2.3)])
let nodeThree = Node("third", 3.0, [Node("subOne", 3.1, [Node("subSubOne", 3.10)])])
let nodeFour = Node("fourth", 4.0, [])
nodes.append(nodeOne)
nodes.append(nodeTwo)
nodes.append(nodeThree)
nodes.append(nodeFour)
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
}
Screenshots
TreeController Bindings
Attributes Inspector:
Bindings Inspector:
OutlineView Bindings
Bindings Inspector:
NSTableColumn Inspector
Bindings Inspector:
Table View Cell Inspector
Bindings Inspector: