Re: Bindings Problem: [change valueForKey:NSKeyValueChangeIndexesKey] always returns NULL!!
Re: Bindings Problem: [change valueForKey:NSKeyValueChangeIndexesKey] always returns NULL!!
- Subject: Re: Bindings Problem: [change valueForKey:NSKeyValueChangeIndexesKey] always returns NULL!!
- From: Andre <email@hidden>
- Date: Thu, 25 Oct 2007 16:43:17 +0900
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 平成 19/10/25, at 16:28, email@hidden 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!
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden