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 788457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:22:05+00:00 2026-05-14T21:22:05+00:00

I have an NSOutlineView with checkboxes. I have the checkbox state bound to a

  • 0

I have an NSOutlineView with checkboxes. I have the checkbox state bound to a node item with the key shouldBeCopied. In the node item I have the getters and setters like so:

-(BOOL)shouldBeCopied {
    if([[self parent] shouldBeCopied])
        return YES;
    return shouldBeCopied;
}

-(void)setShouldBeCopied:(BOOL)value {
    shouldBeCopied = value; 
    if(value && [[self children] count] > 0)
        [[self delegate] reloadData];
}

The idea here is that if the parent is checked, so should the children. The problem I’m having is that when I check the parent, it does not update that view of the children if they are already expanded. I can understand that it should not be updated by the bindings because i’m not actually changing the value. But should reloadData not cause the bindings to re-get the value, thus calling -shouldBeCopied for the children? I have tried a few other things such as -setNeedsDisplay and -reloadItem:nil reloadChildren:YES but none work. I’ve noticed that the display gets refreshed when I swap to xcode and then back again and that’s all I want, so how do I get it to behave that way?

  • 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-05-14T21:22:06+00:00Added an answer on May 14, 2026 at 9:22 pm

    I have an NSOutlineView with checkboxes. I have the checkbox state bound to a node item with the key shouldBeCopied.

    Are you binding the column or the cell? You should bind the column.

    -(BOOL)shouldBeCopied {
        if([[self parent] shouldBeCopied])
            return YES;
        return shouldBeCopied;
    }
    

    Would it not be better to use the child’s value first? If nothing else, it’s cheaper to retrieve (no message required).

    The amended getter would then look like this:

    - (BOOL) shouldBeCopied {
         return (shouldBeCopied || [[self parent] shouldBeCopied]);
    }
    

    The problem I’m having is that when I check the parent, it does not update that view of the children if they are already expanded.

    There are two solutions. One is cleaner and will work on 10.5 and later. The other is slightly dirty and will work on any version of Mac OS X.

    The dirty solution is to have the parent, from the setter method, post KVO notifications on behalf of all of its children. Something like:

    [children performSelector:@selector(willChangeValueForKey:) withObject:@"shouldBeCopied"];
    //Actually change the value here.
    [children performSelector:@selector(didChangeValueForKey:) withObject:@"shouldBeCopied"];
    

    This is dirty because it has one object posting KVO notifications about a property of another object. Each object should only claim to know the values of its own properties; an object that claims to know the values of another object’s properties risks being wrong, leading to wrong and/or inefficient behavior, not to mention a propensity for the code to induce headache.

    The cleaner solution is to have each object observe this property of its parent. Pass the NSKeyValueObservingOptionPrior option when adding yourself as an observer in order to get a notification before the change (which you’ll respond to, in the observation method, by sending [self willChangeValueForKey:]) and a notification after the change (which you’ll respond to, in the observation method, by sending [self didChangeValueForKey:]).

    With the clean solution, each object only sends KVO notifications about its own property changing; no object is posting notifications about other objects’ properties.

    You might be tempted to have the child not send itself these KVO notifications when its own value for the property is YES, because in that case the parent’s value doesn’t matter. You shouldn’t, though, as this would only work for children; if a farther-down descendant has the property set to NO, then that object’s ancestors’ values matter after all, and that object will only get the notification if every one of its ancestors posts it.

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

Sidebar

Related Questions

I have a View-based NSOutlineView bound to a NSTreeController. Everything seems to work correctly
I'm using an NSOutlineView with the function - (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item defined so it
I have a tree-like model I'd like to show in an NSOutlineView using an
I have an NSTreeController bound to an NSOutlineView (no core data). From Cocoa's reference:
I have properly setup an NSOutlineView with its data source and it's working great.
I have two columns in my NSOutlineView. One is a Text and image cell
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I have a fairly pedestrian non-editable NSOutlineView setup. In the bindings for the outline
OK so I've got a sidebar built using an NSOutlineView. I currently have two
Have following listener for keyboard ArrowDown event(it's key code is 40 ): window.onload =

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.