isa-swizzling

My isa-swizzling breaks KVO

这一生的挚爱 提交于 2019-11-29 04:47:00
I'm trying to implement isa swizzling because I need some actions to happen in dealloc method of certain object. I'm overriding - (Class)class; method to return original class (as KVO does). Everything works fine, until I try to add observer to swizzled object. It just crashes. 0x00000000 in 0x00000000 () 0x0091d22a in _NSKeyValueRetainedObservationInfoForObject () 0x0092ec88 in -[NSObject(NSKeyValueObserverRegistration) _addObserver:forProperty:options:context:] () 0x0092d6fd in -[NSObject(NSKeyValueObserverRegistration) addObserver:forKeyPath:options:context:] () Here is implementation of

My isa-swizzling breaks KVO

坚强是说给别人听的谎言 提交于 2019-11-27 18:56:08
问题 I'm trying to implement isa swizzling because I need some actions to happen in dealloc method of certain object. I'm overriding - (Class)class; method to return original class (as KVO does). Everything works fine, until I try to add observer to swizzled object. It just crashes. 0x00000000 in 0x00000000 () 0x0091d22a in _NSKeyValueRetainedObservationInfoForObject () 0x0092ec88 in -[NSObject(NSKeyValueObserverRegistration) _addObserver:forProperty:options:context:] () 0x0092d6fd in -[NSObject