I spent a lot of time on this problem and wanted to get it through an accessory. I wanted to clarify in the answer for those who came. This is what I did:
@property (nonatomic,readonly,getter=getTheFoos) NSMutableArray* foos;
Then, obviously, it is implemented:
- (NSMutableArray*)getTheFoos { return [self mutableArrayValueForKey:@"foos"]; }
If you were careful, getFoos appears to be an (undocumented) KVC accessory because it sends it in the same loop.
Then on KVO:
Test* test= [[Test alloc] init]; NSObject* obj= [[NSObject alloc] init]; NSMutableArray* arrTheData= test.foos; [test.foos insertObject:obj atIndex:0]; [arrFoos insertObject:obj atIndex:0];
arrFoos can read the updated mutated array (there will be two objects in it), but inserting into it will not start KVO. Somewhere in my adventures, I saw that returning from mutableArrayValueForKey: does not return NSMutableArray *, but a subclass of this, which may be the reason for this.
source share