EddyBorja / MLPAutoCompleteTextField

UITextfield subclass with autocomplete menu. For iOS.
Other
1.21k stars 222 forks source link

Crash on deallocation due to KVO still registered #110

Closed bestimmaa closed 8 years ago

bestimmaa commented 8 years ago
2016-10-19 14:50:23.817 Klickrent Dev[98467:17145028] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x7aaf4a00 of class MLPAutoCompleteTextField was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x7b1c7f60> (
<NSKeyValueObservance 0x7b107e90: Observer: 0x7aaf4a00, Key path: borderStyle, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x7b107ef0>
<NSKeyValueObservance 0x7a6b17c0: Observer: 0x7aaf4a00, Key path: autoCompleteTableView.hidden, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x7a6b1720>
<NSKeyValueObservance 0x7a6ed420: Observer: 0x7aaf4a00, Key path: backgroundColor, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x7a6ed400>
<NSKeyValueObservance 0x7a6ed7e0: Observer: 0x7aaf4a00, Key path: autoCompleteTableAppearsAsKeyboardAccessory, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x7a6ed7c0>
)'
bestimmaa commented 8 years ago

And I have no idea how this can happen. Dealloc is implemented and does deregister all observers...

bestimmaa commented 8 years ago

This is mostly due to a change in iOS 10 as described here: https://forums.developer.apple.com/thread/53636

bestimmaa commented 8 years ago

Turns out... the version obtained from cocoapods still includes the init method which is responsible for registering the KVO twice. The source over at the repository already includes this fix!