1

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:

enter image description here

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:

enter image description here

Bindings Inspector:

enter image description here

OutlineView Bindings

Bindings Inspector:

enter image description here

NSTableColumn Inspector

Bindings Inspector:

enter image description here

Table View Cell Inspector

Bindings Inspector:

enter image description here

koen
  • 5,383
  • 7
  • 50
  • 89
  • Is the outline view view based or cell based? To which key is the binding of the first column? The last two images are the same, did you bind the column or the cell? – Willeke Apr 27 '21 at 20:26

0 Answers0