Adding objects from one array to another and and Key Value Observing
Adding objects from one array to another and and Key Value Observing
- Subject: Adding objects from one array to another and and Key Value Observing
- From: "Mazen M. Abdel-Rahman" <email@hidden>
- Date: Wed, 09 Jun 2010 13:19:49 -0700
Hi All,
I have a view class that observes changes in a model class's array via KVO. Unfortunately - when ever the array is updated - the updates are sent to the view one at at a time.
In my model class I have the following line:
NSMutableArray * eventsArrayProxy = [self mutableArrayValueForKey:@"events"];
[eventsArrayProxy addObjectsFromArray:appointments];
Which naturally causes the following method in my view class to be invoked:
-(void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
My problem is that observeValueForKeyPath.. is invoked once for each and every single item in the appointments array (the array being added) - rather than once for all of them. Is this standard behavior? And is there a way to have it call observeValueForKeyPath.. one time for all the objects being added?
In my case - I am sometimes adding as much as a thousand or more objects - so it is a severe performance issue right now. If this is the only way KVO works for arrays then I will have to find another way around it - but I'm hopeful perhaps there's some way this can be done.
Thanks for your help,
Mazen Abdel-Rahman
_______________________________________________
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