Created
October 15, 2019 14:20
-
-
Save uc-compass-bot/c058c802eab03f77b9511007422f5dfc to your computer and use it in GitHub Desktop.
Example Of Retain Cycle On Delegate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ParentViewController: UIViewController, ChildViewControllerProtocol { | |
let childViewController = ChildViewController() | |
func prepareChildViewController() { | |
childViewController.delegate = self // ❌ Strong reference, retain cycle | |
} | |
} | |
protocol ChildViewControllerProtocol: class {} | |
class ChildViewController: UIViewController { | |
var delegate: ChildViewControllerProtocol? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment