Deinit never called

前端 未结 13 1831
清歌不尽
清歌不尽 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:03

    I had similar problem. I added empty deinit method to my class and added breakpoint:

    deinit {
    
    }
    

    As result it's never called.
    As soon as I add some code to the body it started working as expected:

    deinit {
        print("deinit called")
    }
    

    So be sure that your deinit method isn't empty.
    PS. I am using Swift 2, Xcode 7.1

提交回复
热议问题