Deinit never called

前端 未结 13 1853
清歌不尽
清歌不尽 2020-11-30 03:51

I\'m creating a ViewController object an pushing it to a navigation controller. When the object is being popped from the stack - it is not being release and Deinit is not be

13条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 04:13

    I had a timer in my view controller, running every minute to update a label. I put a call in deinit to invalidate the timer, which I'm pretty sure is what I've always done in Objective-C (in dealloc) and it's worked. But it seems a little different in Swift so I moved the time creation/invalidation code to viewWillAppear/viewWillDisappear (which makes more sense really) and everything seems fine now!

提交回复
热议问题