jcavar / refresher

DEPRECATED: Pull to refresh in Swift
MIT License
873 stars 99 forks source link

Swift KVO crash after deinit #40

Open Maru-zhang opened 6 years ago

Maru-zhang commented 6 years ago

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.

jcavar commented 6 years ago

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

Maru-zhang commented 6 years ago

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

Maru-zhang commented 6 years ago

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

darekxan commented 6 years ago

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>
)'
jcavar commented 6 years ago

Are you able to reproduce this consistently?