Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

#Steps ##Create Basic Project Refer to commit till #fa626ee. ##Add Model Class of "Node" Refer to commit till #e302b91.

class Node: NSObject {
  var title = "Node"
  var isGroup = false
  var children = [Node]()
  weak var parent: Node?
  override init() {
  init(title: String) {
    self.title = title
  func isLeaf() -> Bool {
    return children.isEmpty

##Add UI Controls Refer to commit till #5dee8d1. After done, the UI looks like:

##Implement NSOutlineViewDataSource Refer to commit till #c467d0b. Notes:

  • Set NSOutlineView's dataSource to File's Owner. ![](./_image/Outline/Data Source.jpg)

  • Bind value "Table Cell View" to "Table Cell View" > Model Key Path: objectValue.title.

After done, the UI looks like:

##Implement NSOutlineViewDelegate Refer to commit till #300948e.


  • Set NSOutlineView's delegate to File's Owner.

##Add Node and Group Refer to commit till #f18c61f.


  • The logic to add node or group in correct position is very boring. That's why binding will be a good friend.
  • There're 2 ways to insert item in outline view. One is update the data modal, then call NSOutlineView.reloadData(). But this will let UI flash. So it's better to manually insert item in outline view (e.g., use NSOutlineView.insertItemsAtIndexes). Another benefit is could use animation during inserting.

After done, you can add node or group. The UI looks like:

##Implement other UI Operations The operations include remove, edit, move up and move down. It's not hard. But the logic is complex and boring. Be careful. Refer to commit till #3f7ffaa.


  • Could create a dynamic property (e.g., dynamic var removeButtonEnabled = false), and then bind a control's enable property to it. e.g., ![](./_image/Outline/Bind Enabled.jpg)

  • Should set table view cell's behavior as "Editable" to edit it.

You can’t perform that action at this time.