KVO - deallocation with observers attached
KVO - deallocation with observers attached
- Subject: KVO - deallocation with observers attached
- From: Jonathan Mitchell <email@hidden>
- Date: Wed, 31 May 2017 23:02:15 +0100
It is common for deallocating objects to abort if they have observers still registered.
However in some cases it seems that an object can get deallocated with observers attached and not abort.
I have instrumented my test case thoroughly and overridden -setObservationInfo: to log the observation changes as below.
The Data_Test object is deallocated with non nil -observationInfo and yet it does not abort.
Why does this occur?
I am sorting through some observer related crash reports just trying to figure out possible causes.
The Data_Test object is heavily observed throughout its lifetime both by bindings and explicit observations.
macOS 10.12
2017-05-31 22:49:01.616632+0100 MyApp Data_Test (0x11336d100) SetObservationInfo
2017-05-31 22:49:01.616656+0100 MyApp oldObservationInfo : <NSKeyValueObservationInfo 0x600002a31b80> (
<NSKeyValueObservance 0x608000c53f20: Observer: 0x117411da0, Key path: name, Options: <New: NO, Old: NO, Prior: NO> Context: 0x10075a4b8, Property: 0x61000044abc0>
<NSKeyValueObservance 0x60000064ec10: Observer: 0x600000241500, Key path: aeIsPostponementLetterFlagEnabled, Options: <New: NO, Old: NO, Prior: NO> Context: 0x0, Property: 0x608000a51280>
)
2017-05-31 22:49:01.616692+0100 MyApp newObservationInfo : <NSKeyValueObservationInfo 0x600002a31cc0> (
<NSKeyValueObservance 0x608000c53f20: Observer: 0x117411da0, Key path: name, Options: <New: NO, Old: NO, Prior: NO> Context: 0x10075a4b8, Property: 0x61000044abc0>
)
2017-05-31 22:49:04.188226+0100 MyApp Data_Test (0x11336d100) dealloc
Thanks
Jonathan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden