FROM : George Orthwein
DATE : Tue Jul 18 20:39:06 2006
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
DATE : Tue Jul 18 20:39:06 2006
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
| Related mails | Author | Date |
|---|---|---|
| Hannes Petri | Jul 12, 00:43 | |
| Hannes Petri | Jul 12, 13:00 | |
| George Orthwein | Jul 12, 15:25 | |
| Hannes Petri | Jul 12, 15:56 | |
| Matt Neuburg | Jul 12, 19:35 | |
| Bill Northcott | Jul 13, 01:41 | |
| Matt Neuburg | Jul 13, 16:46 | |
| Hannes Petri | Jul 14, 12:41 | |
| Matt Neuburg | Jul 14, 17:47 | |
| George Orthwein | Jul 14, 22:22 | |
| Matt Neuburg | Jul 14, 22:32 | |
| Hannes Petri | Jul 17, 11:19 | |
| George Orthwein | Jul 18, 20:39 |






Cocoa mail archive

