Is retain cycle posible in computed properties?

Viewed 825

I found a snipped of code there was a class, and that class had computed property of CustomViewController(inherits UIViewController) and in the getter of this property, they store self. The best way hot to describe this is via code

class SomeClass: {

    var alertViewController: UIViewController? {
        if self.wasRequested {
            return self.chatController
        } else {
            let vc = CutomVC(nibName: "SomeNibName", bundle: nil)
            vc.alert = self
            return vc
        }
    }
}

Now when you present that viewcontroller will this ever be de-inited? Is this retain cycle?

Thank you

2 Answers

Just to simplify things to other people interested in quick answer, NO this isn't a retail cycle, deinit is always called in this case.

Related