• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Adding objects from one array to another and and Key Value Observing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Adding objects from one array to another and and Key Value Observing
      • From: Ken Thomases <email@hidden>
    • Re: Adding objects from one array to another and and Key Value Observing
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Problem opening large files into NSDocument
  • Next by Date: Re: Problem opening large files into NSDocument
  • Previous by thread: Re: Question about scaling text within a subView
  • Next by thread: Re: Adding objects from one array to another and and Key Value Observing
  • Index(es):
    • Date
    • Thread