简体   繁体   中英

Why will app crash if did not remove KVO observer before dealloc?

I understand we need to remove KVO observe before instance dealloc.

But Why would this crash happen?

If you use the Swift4 KVO, then you don't need to. It's safely handled.

That being said it was needed before, because sending messages to deallocated instances crashes the app. The concept is similar to the answer mentioned here .

To read more about the memory management of the Swift3 vs Swift4 KVO see here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM