refresher icon indicating copy to clipboard operation
refresher copied to clipboard

Swift KVO crash after deinit

Open Maru-zhang opened this issue 7 years ago • 5 comments

hello, in your demo project, the view controller would't be released(memery leak).After I added unowned self, the view controller has deinit, but demo will crash. It will append <= iOS11, it's look like system bug.

Maru-zhang avatar Dec 27 '17 07:12 Maru-zhang

Is this when you go back while pull to refresh is loading? I think weak self should help in this situation.

jcavar avatar Jan 02 '18 12:01 jcavar

I'm afraid not.I tried, but it still crash.You can try this on any simulator that <= iOS11.

Maru-zhang avatar Jan 03 '18 02:01 Maru-zhang

The reason is the ScrollView own a NSKeyValueObservation instance that observer the same ScrollView.But on iOS11, That all work.

Maru-zhang avatar Jan 03 '18 02:01 Maru-zhang

Same here

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x7ff436072600 of class UITableView was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x608000427ce0> (
<NSKeyValueObservance 0x6080004417a0: Observer: 0x610000478780, Key path: contentOffset, Options: <New: NO, Old: NO, Prior: NO> Context: 0x0, Property: 0x61000044d500>
)'

darekxan avatar Feb 21 '18 16:02 darekxan

Are you able to reproduce this consistently?

jcavar avatar Feb 21 '18 17:02 jcavar