Re: Bindings Problem: [change valueForKey:NSKeyValueChangeIndexesKey] always returns NULL!!

  • Ok, well, after reading further on MMalc's awesome bindings page, I
    came across this:

    "The change dictionary doesn't contain old and new values. This is not
    your fault, it's due to a bug in the controller. This bug will not be
    fixed in the forseeable future."

    Great!!!!!!!!  Well, I will file a bug. Please everyone, this is
    ridiculous! Please help to elevate this bug so it gets fixed......
    oooh only 1 more day and bye bye nda....
    there's something I would like to say concerning leopard...........

    On $BJ?@.(B 19/10/25, at 16:28, <listposter...> wrote:
    > Hi everyone.
    >
    > Its been a long time since I posted to these lists!
    > Well, I've got a problem.
    >
    > I've got a custom graphics view that is bound to an NSTreeController
    > that provides the content for said custom view.
    > Its set up to be bound to the NSTreeController, and I have
    > registered as an observer using:
    > [controller addObserver:self forKeyPath:@"arrangedObjects" options:
    > (NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld)
    > context:(id)CONTENT_CONTEXT];
    >
    > The Code that observes changes are as follows:
    > - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:
    > (id)object change:(NSDictionary *)change context:(void *)context
    > {
    > if (context == CONTENT_CONTEXT) {
    > NSKeyValueChange changeKind = [[change
    > valueForKey:NSKeyValueChangeKindKey] intValue];
    >
    > if (NSKeyValueChangeRemoval == changeKind) {
    > //Remove old Values
    > NSArray *changedIndexes = [change
    > valueForKey:NSKeyValueChangeIndexesKey];
    > NSArray *objectsToRemove = [change
    > valueForKey:NSKeyValueChangeOldKey];
    > NSLog(@"Changed Indexes are %@, removedObjects are
    > %@",changedIndexes,objectsToRemove);
    > }
    >
    > if (NSKeyValueChangeInsertion == changeKind) {
    > //Insert new Values
    > NSArray *changedIndexes = [change
    > valueForKey:NSKeyValueChangeIndexesKey];
    > NSArray *objectsToInsert = [change
    > valueForKey:NSKeyValueChangeNewKey];
    > NSLog(@"Changed Indexes are %@, inserted indexes are
    > %@",changedIndexes,objectsToInsert);
    > }
    >
    > if (NSKeyValueChangeReplacement == changeKind) {
    > //Remove old Values and replace with new ones
    > }
    >
    > if (NSKeyValueChangeSetting == changeKind) {
    > //Remove all old Values and replace with all new ones
    > NSArray *changedIndexes = [change
    > valueForKey:NSKeyValueChangeIndexesKey];
    > NSArray *objectsToInsert = [change
    > valueForKey:NSKeyValueChangeNewKey];
    > NSArray *objectsToRemove = [change
    > valueForKey:NSKeyValueChangeOldKey];
    >
    > NSLog(@"Changed Indexes are %@, inserted indexes are %@,
    > removedObjects are
    > %@",changedIndexes,objectsToInsert,objectsToRemove);
    >
    > }
    >
    >
    > Here the NSLog always prints out:
    > Changed Indexes are (null), inserted indexes are <null>,
    > removedObjects are <null>
    >
    > Furthermore, the only changes that seem to get registered from the
    > NSTreeController are NSKeyValueChangeSetting. I never get
    > NSKeyValueChangeInsertion for example....
    > IOW, NSTreeController, like NSArrayController, doesn't insert new or
    > remove single additions or removals, it removes and the reinserts
    > everything at once....
    > Aside from not even being able to get the changed indexes, how am I
    > supposed to efficiently program a view with many items, when I have
    > to remove and add everything over and over again??
    >
    > After looking at MMalc's bindings examples, I came across this gem:
    >
    > /*
    > Should be able to use
    > NSArray *oldGraphics = [change
    > objectForKey:NSKeyValueChangeOldKey];
    > etc. but the dictionary doesn't contain old and new arrays.
    > */
    >
    > Great!! So uh, what am I supposed to do???
    >
    >
    > Any help would be appreciated!
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today