KVO does not notify when a weakly observed property goes to nil

Originator:jurewitz
Number:rdar://12219416 Date Originated:31-Aug-2012 04:34 PM
Status:Open Resolved:
Product:Mac OS X Product Version:12B19
Classification:Serious Bug Reproducible:Always
 
31-Aug-2012 04:34 PM Michael Jurewitz:
Summary:
Key Value Observing does not notify the observing object when a weakly held observed object goes to nil as a result of being deallocated.

Steps to Reproduce:
1. Inspect attached sample project
2. Notice that Class A weakly holds an instance of Class B.
3. Instance `a` of Class A is subscribed to watch for changes to instance b's name.
4. Notice `a` is properly notified of changes to `b's name.
5. Notice that once `b's last strong reference goes away, it is deallocated.
6. `a` is never notified via KVO that `b` has gone away or changed after this point.

Expected Results:
KVO should inform observers when observed values change, particularly as a result of being deallocated via the __weak subsystem. This is likely an enormous source of subtle bugs and unexpected behavior. It should be possible to be weakly interested in an object from a graph management perspective and still be informed of changes to that object via KVO. This bug basically makes it impossible to take a KVO interest in a weakly held object.

Actual Results:
KVO actually detects this situation enough to log to the console. However, instead of being of any further help and informing the observing objects, it just silently fails.


31-Aug-2012 04:34 PM Michael Jurewitz:
'WeakTest.zip' was successfully uploaded

Comments

Duped as 12479339

By heath.borders at Oct. 11, 2012, 4:30 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!