NSArrayController replace and observeValueForKeyPath:
NSArrayController replace and observeValueForKeyPath:
- Subject: NSArrayController replace and observeValueForKeyPath:
- From: Christian Schneider <email@hidden>
- Date: Tue, 29 Nov 2005 16:20:53 +0100
Hi all,
I've got a rather complicated setup where an NSArrayController is
programmatically bound to my model object. The model implements the KVO
method -replaceObjectInClipsArrayAtIndex:withObject: which I prefer to
first removing the old object and then inserting the new object, because any
change is saved in a database.
As far as I understand an array controller bound to my model with the key
path "clipsArray" should be notified when the above replace method is
called. However, that didn't work for me so I've overwritten
bind:toObject:withKeyPath:options: in my subclass of NSArrayController with
- (void)bind:(NSString *)binding toObject:(id)observableController
withKeyPath:(NSString *)keyPath options:(NSDictionary *)options
{
[observableController addObserver:self
forKeyPath:keyPath
options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld
context:NULL];
[super bind:binding toObject:observableController withKeyPath:keyPath
options:options];
}
Is that really the way to do that or might I have missed something?
Second, is there really no way to replace an object with another object via
an array controller apart from remove/insert and if so why?
chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden