vhesener / Closures

Swifty closures for UIKit and Foundation
MIT License
1.74k stars 146 forks source link

UIView not release #39

Closed iBinh closed 5 years ago

iBinh commented 6 years ago

addTapGesture or longGesture for UIView instance cause UIViewController not release when pop or dismiss

vhesener commented 6 years ago

Can you post some example code?

vhesener commented 6 years ago

Created a very simple app to show this is working as expected. Basically, a tap presents a new ViewController and a long press dismisses it. If you set a breakpoint in the deninit method, you can see that the presented ViewController does not retain anything.

See below and try for yourself. Also check that you don't have any retain cycles in your closures.

import UIKit
import Closures

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        view.addTapGesture { [weak self] _ in
            self?.present(ViewController(), animated: true)
        }

        view.addLongPressGesture { [weak self] _ in
            self?.dismiss(animated: true)
        }
    }

    deinit {
        NSLog("deinitialized %@", self)
    }
}