我在我的Objective-C++類(MyObjectiveCppClass)以下-dealloc
實現:調試__weak變量的不正確使用客觀的C++類
- (void)dealloc {
if (_my_iVar) {
[_my_iVar doSomeSlowishCleanUp];
}
}
每當這個-dealloc
方法被稱爲我得到像一堆警告:
objc[1254]: __weak variable at 0x1662a38c8 holds 0x19c70f408 instead of 0x160abe000. This is probably incorrect use of objc_storeWeak() and objc_loadWeak(). Break on objc_weak_error to debug.
當我在objc_weak_error
打破堆棧看起來是這樣的:
#0 0x0000000182395330 in objc_weak_error()
#1 0x00000001823959d0 in weak_clear_no_lock()
#2 0x000000018239f1e8 in objc_object::clearDeallocating_slow()()
#3 0x000000018238e074 in objc_destructInstance()
#4 0x0000000182d25fac in -[NSObject(NSObject) __dealloc_zombie]()
----> #5 0x00000001000a6c30 in -[MyObjectiveCppClass .cxx_destruct]
#6 0x0000000182382b54 in object_cxxDestructFromClass(objc_object*, objc_class*)()
#7 0x000000018238e040 in objc_destructInstance()
#8 0x0000000182d25fac in -[NSObject(NSObject) __dealloc_zombie]()
----> #9 0x00000001000a691c in -[MyObjectiveCppClass dealloc]
#10 0x0000000100611bc4 in -[SomeViewB .cxx_destruct]
#11 0x0000000182382b54 in object_cxxDestructFromClass(objc_object*, objc_class*)()
#12 0x000000018238e040 in objc_destructInstance()
#13 0x0000000182d25fac in -[NSObject(NSObject) __dealloc_zombie]()
#14 0x0000000188233a90 in -[UIResponder dealloc]()
#15 0x0000000187e78b08 in -[UIView dealloc]()
#16 0x0000000187f60700 in -[UIScrollView dealloc]()
#17 0x0000000182c049b4 in -[__NSArrayM dealloc]()
#18 0x00000001006495cc in -[SomeViewA .cxx_destruct]
有沒有人有任何提示如何解決這些警告?
那麼解決方案是什麼?我遇到了類似的問題,但有第三方庫。 –
你認爲解決方案是什麼?! –