2
은 가정하자 나는이 같은 클래스가 있습니다 때문에 theData 재산 (다른 KVO의 complience 방법을 건너 뛰고) 및 mutableArrayValueForKeyPath을 통해 내가 삽입을 관찰 할 수의 KVO의 complience의 여기NSMutableArray에서 개별 요소의 변경 사항을 관찰하는 방법은 무엇입니까?
@interface MyClass : NSObject
@property (nonatomic, strong, getter=theDataGetter) NSMutableArray* theData;
@end
@implementation MyClass
-(NSMutableArray *)theDataGetter
{
return [self mutableArrayValueForKeyPath:@"theData"];
}
@end
를 업데이트, 제거 theData 속성 위에있는 작업 이제이 배열에 변경 가능한 사전이 있다고 가정합니다.
self.obj = [[MyClass alloc] init];
_obj.theData = [[NSMutableArray alloc] initWithObjects:
[NSMutableDictionary dictionaryWithObjectsAndKeys:@"The one with glasses.",@"description",@"Manny",@"name", nil],
[NSMutableDictionary dictionaryWithObjectsAndKeys:@"Looks a little like Governor Dewey.",@"description",@"Moe",@"name", nil],
[NSMutableDictionary dictionaryWithObjectsAndKeys:@"The one without a mustache.",@"description",@"Jack",@"name", nil],
nil];
지금 내 질문은 theData 배열의 어떤 사전의 "설명"키의 값 변화를 관찰하는 방법이다. 첫 번째 물체의 설명 키의 값이 이제는 다른 값으로 변경되는 것을 관찰하고 싶다고 가정 해 보겠습니다.