NSOutlineView implementation guide After Data Source Change on macOS 13.6
I'm optimizing some code but I'm sure I'm missing something obvious here, but I'm sure I'm missing something obvious here, but I'm having an scenario with my `NSOutlineView` not updating when I modify the underlying data source... I've implemented the required data source methods and even called `reloadData()` on the outline view after updating the data, but it still doesn't reflect the changes. Here's a simplified version of my implementation: ```swift class MyOutlineViewController: NSViewController, NSOutlineViewDataSource { @IBOutlet weak var outlineView: NSOutlineView! var items: [MyItem] = [] override func viewDidLoad() { super.viewDidLoad() outlineView.dataSource = self loadData() } func loadData() { // Simulate data loading items = [MyItem(name: "Item 1"), MyItem(name: "Item 2")] outlineView.reloadData() } func outlineView(_ outlineView: NSOutlineView, numberOfChildrenOfItem item: Any?) -> Int { return items.count } func outlineView(_ outlineView: NSOutlineView, child index: Int, ofItem item: Any?) -> Any { return items[index] } func outlineView(_ outlineView: NSOutlineView, isItemExpandable item: Any) -> Bool { return false } } ``` I can see in the debugger that `items` is being updated correctly, but the outline view isn't reflecting these changes. I even verified that `reloadData()` is being called after the data is set. I also tried using `beginUpdates()` and `endUpdates()` as follows: ```swift outlineView.beginUpdates() outlineView.reloadData() outlineView.endUpdates() ``` But this didn't help either. Is there something I'm missing? Any insights or suggestions would be greatly appreciated! This is happening in both development and production on Ubuntu 20.04. Thanks for taking the time to read this! I've been using Swift for about a year now. What's the correct way to implement this? My team is using Swift for this web app. Any ideas how to fix this?