• 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
Re: Getting added object with KVO
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting added object with KVO


  • Subject: Re: Getting added object with KVO
  • From: George Orthwein <email@hidden>
  • Date: Tue, 18 Jul 2006 14:39:06 -0400

On Jul 17, 2006, at 5:19 AM, Hannes Petri wrote:
- (void)insertObject:(id)object inCollectionsAtIndex:(int)index
{
[self didChange:NSKeyValueChangeInsertion valuesAtIndexes: [NSIndexSet indexSetWithIndex:index] forKey:@"collections"];
[collections insertObject:object atIndex:index];
[self didChange:NSKeyValueChangeInsertion valuesAtIndexes: [NSIndexSet indexSetWithIndex:index] forKey:@"collections"];
}

First line should be willChange. However, you shouldn't need any willChange/didChange calls at all, unless you are using Manual observing. Automatic should work fine for you. So try removing those lines.


http://developer.apple.com/documentation/Cocoa/Conceptual/ KeyValueObserving/Concepts/AutoVsManual.html


The Manual bindings example may also be helpful ("Manual" here unrelated to Manual KVO), even though it demonstrates bind:toObject:withKeyPath:options rather than addObserver:forKeyPath:options:context:.
I added a custom view and was able to observe the itemsArray and get a valid change dictionary for the inserted/removed objects.


http://homepage.mac.com/mmalc/CocoaExamples/controllers.html

Hope that helps,
George

_______________________________________________
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


References: 
 >Getting added object with KVO (From: Hannes Petri <email@hidden>)
 >Re: Getting added object with KVO (From: Hannes Petri <email@hidden>)

  • Prev by Date: Re: OpenGL with Cocoa?
  • Next by Date: Re: OpenGL with Cocoa?
  • Previous by thread: Re: Getting added object with KVO
  • Next by thread: Re: Getting added object with KVO
  • Index(es):
    • Date
    • Thread