I am implementing the DocumentsManager class on iOS, and I want the to-many property called documents to comply with KVO requirements. This basically works, and my KVO access methods and mutators are called. However, my concern is that any change made directly to the NSMutableArray proxy returned by calling mutableArrayValueForKey: in my instance does not notify observers.
So, this code notifies me about the insertion of @"aaa" , but not about @"bbb" , although both of them are actually inserted into visible ones in docsProxy . Is this expected behavior? If so, what is the advantage of using mutableArrayValueForKey: :?
NSMutableArray *docsProxy = [[DocumentsManager instance] mutableArrayValueForKey:@"documents"]; [[DocumentsManager instance] addObserver:self forKeyPath:@"documents" options:NSKeyValueObservingOptionNew context:NULL]; [[DocumentsManager instance] insertObject:@"aaa" inDocumentsAtIndex:0];
source share