{"action":"closed","issue":{"url":"https://api.github.com/repos/Microsoft/WinObjC/issues/289","labels_url":"https://api.github.com/repos/Microsoft/WinObjC/issues/289/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/WinObjC/issues/289/comments","events_url":"https://api.github.com/repos/Microsoft/WinObjC/issues/289/events","html_url":"https://github.com/Microsoft/WinObjC/issues/289","id":122980943,"number":289,"title":"KVO: error when observing nested property within dictionary","user":{"login":"triplef","id":6037,"avatar_url":"https://avatars.githubusercontent.com/u/6037?v=3","gravatar_id":"","url":"https://api.github.com/users/triplef","html_url":"https://github.com/triplef","followers_url":"https://api.github.com/users/triplef/followers","following_url":"https://api.github.com/users/triplef/following{/other_user}","gists_url":"https://api.github.com/users/triplef/gists{/gist_id}","starred_url":"https://api.github.com/users/triplef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/triplef/subscriptions","organizations_url":"https://api.github.com/users/triplef/orgs","repos_url":"https://api.github.com/users/triplef/repos","events_url":"https://api.github.com/users/triplef/events{/privacy}","received_events_url":"https://api.github.com/users/triplef/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/WinObjC/labels/Fixed","name":"Fixed","color":"009800"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-18T16:31:48Z","updated_at":"2015-12-23T02:30:33Z","closed_at":"2015-12-23T02:30:33Z","body":"We have the following setup:\r\n\r\n1. Our test class \"Test\" has a property `a` of type ClassA\r\n2. ClassA has a property `dict` of type NSMutableDictionary\r\n3. That dictionary has a key-value pair of `b = <ClassB instance>`\r\n4. ClassB has a primitive property `someProperty`\r\n\r\nWe are observing `a.dict.b.someProperty`. When triggering a KVO-notification by setting the property `a` we get the following error:\r\n\r\n> NSInvalidArgumentException\r\n> Reason: Class ClassA is not KVC compliant for key b.\r\n\r\nNote that ClassA has no property named `b`, but instead `b` is the key used in the dictionary. Also, the exception occurs *after* `-observeValueForKeyPath:` is called.\r\n\r\nCalling `-[Test test]` in the following code reproduces the issue:\r\n\r\n```objc\r\n@interface ClassA : NSObject\r\n@property (strong, nonatomic) NSMutableDictionary *dict;\r\n@end\r\n\r\n@implementation ClassA\r\n@end\r\n\r\n@interface ClassB : NSObject\r\n@property (assign, nonatomic) float someProperty;\r\n@end\r\n\r\n@implementation ClassB\r\n@end\r\n\r\n@interface Test : NSObject\r\n@property (strong, nonatomic) ClassA *a;\r\n@end\r\n\r\n@implementation Test\r\n\r\n- (void)test\r\n{\r\n\tClassB *b = [[ClassB alloc] init];\r\n\tb.someProperty = 1.23;\r\n\r\n\tNSMutableDictionary *dict = [NSMutableDictionary dictionary];\r\n\t[dict setObject:b forKey:@\"b\"];\r\n\r\n\tClassA *a = [[ClassA alloc] init];\r\n\ta.dict = dict;\r\n\r\n\tself.a = a;\r\n\r\n\t[self addObserver:self forKeyPath:@\"a.dict.b.someProperty\" options:0 context:nil];\r\n\r\n\tself.a = a;\t// triggers KVO notification\r\n}\r\n\r\n- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context\r\n{\r\n}\r\n\r\n@end\r\n```"}}