Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7912517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:37:42+00:00 2026-06-03T13:37:42+00:00

I have a tree-like model I’d like to show in an NSOutlineView using an

  • 0

I have a tree-like model I’d like to show in an NSOutlineView using an NSTreeController.

I was able to set up the bindings and everything works fine as long as I use the NSTreeController’s insert and remove functions to change my model tree. If I try to insert or remove from the model tree directly, in some cases the NSOutlineView isn’t updating.

If I insert an object into an expanded group of objects, it works:

Inserting node

New node showing

But if I try to add the first object to a node, that had no children before, nothing happens. The disclosure triangle isn’t appearing, so I can’t expand it to see the new node.

Inserting new child

enter image description here

If I hover over that node with a new object, it is expanded and I can add the second child with no problems. But the triangle is still invisible:

enter image description here

Finally if I close the parent of all these nodes and open them again (triggering a reload) the triangle suddenly appears:

enter image description here

That’s why I was wondering if I had to manually reload the NSOutlineView’s rows to make the triangle visible, or if I’m messing up something? Thanks!!

UPDATE:

In my Node class I add a new child like this:

- (void)addChild:(MyNode *)child {
    [self willChangeValueForKey:@"childNodes"];
    [children addObject:child];
    [self didChangeValueForKey:@"childNodes"];
}

And I implemented these too (which I set in IB for my NSTreeController):

- (NSArray *)childNodes {
    return [NSArray arrayWithArray:children];
}

- (NSInteger)countOfChildNodes {
    return [children count];
}

- (BOOL)nodeIsLeaf {
    return [children count] < 1;
}

I know that this (especially childNodes) aren’t very optimized, but I’m only experimenting at the moment as in the final version my children will be stored in a C array.

UPDATE 2:

I also tried sending KVO notifications for the other 2 properties too, but that didn’t help either.

- (void)addChild:(MyNode *)child {
    NSLog(@"%@", NSStringFromSelector(_cmd));
    [self willChangeValueForKey:@"nodeIsLeaf"];
    [self willChangeValueForKey:@"countOfChildNodes"];
    [self willChangeValueForKey:@"childNodes"];
    [children addObject:child];
    [self didChangeValueForKey:@"childNodes"];
    [self didChangeValueForKey:@"countOfChildNodes"];
    [self didChangeValueForKey:@"nodeIsLeaf"];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:37:43+00:00Added an answer on June 3, 2026 at 1:37 pm

    You have to make sure that all updates to your model are performed in a Key-Value Observing-compliant manner.

    Cocoa Bindings Programming Topics: Troubleshooting Cocoa Bindings

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In mysql, I have a tree that is represented using the adjacency list model.
I have a tree like structure created out of models using ForeignKey linkages. As
I have a category model. I am using ancestry gem to make it like
Hay, I'm using MPTT to create some tree-like data from a model which contains
I'm trying to implement a tree like structure using a Materialized Path model described
I have a tree-like model where in all situations but one , I want
In my rails app, have a tree-like model like this: class File belongs_to :parent,
I'm using Rails 3.1. I have a model Tree and a model TreeNode, and
I have a tree-like object, managed by Hibernate. The object has a list of
I have a tree panel and I would like to associate an action to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.