// // FeedListViewController.swift // Evergreen // // Created by Brent Simmons on 11/1/17. // Copyright © 2017 Ranchero Software. All rights reserved. // import Cocoa import RSTree final class FeedListViewController: NSViewController { @IBOutlet var outlineView: NSOutlineView! private let treeControllerDelegate = FeedListTreeControllerDelegate() lazy var treeController: TreeController = { TreeController(delegate: treeControllerDelegate) }() } // MARK: - NSOutlineViewDataSource extension FeedListViewController: NSOutlineViewDataSource { func outlineView(_ outlineView: NSOutlineView, numberOfChildrenOfItem item: Any?) -> Int { return nodeForItem(item as AnyObject?).numberOfChildNodes } func outlineView(_ outlineView: NSOutlineView, child index: Int, ofItem item: Any?) -> Any { return nodeForItem(item as AnyObject?).childNodes![index] } func outlineView(_ outlineView: NSOutlineView, isItemExpandable item: Any) -> Bool { return nodeForItem(item as AnyObject?).canHaveChildNodes } private func nodeForItem(_ item: AnyObject?) -> Node { if item == nil { return treeController.rootNode } return item as! Node } }