Skip to content

Instantly share code, notes, and snippets.

@mhuusko5
mhuusko5 / KVOCrash.m
Created December 5, 2016 19:33
KVO with multi-key path where observer is added/removed while non-last-key property is mutated, crashes
/* 2016-12-05 19:29:16.988026 Compass[71668:644974] [General] An uncaught exception was raised
2016-12-05 19:29:16.988060 Compass[71668:644974] [General] Cannot update for observer <TestObserver 0x600000001060> for the key path "nestedObject.nestedField" from <TestObject 0x600000026ee0>, most likely because the value for the key "nestedObject" has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the TestObject class.
2016-12-05 19:29:16.988395 Compass[71668:644974] [General] (
0 CoreFoundation 0x00007fffaa71ee7b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffbf303cad objc_exception_throw + 48
2 CoreFoundation 0x00007fffaa79d99d +[NSException raise:format:] + 205
3 Foundation 0x00007fffac0f5a62 -[NSKeyValueNestedProperty object:withObservance:didChangeValueForKeyOrKeys:recurse:forwardingValues:] + 830
4 Foundation 0x00007fffac0c8e88 NSKe