【发布时间】:2017-08-27 17:05:49
【问题描述】:
我试图了解 xcode 调试工具在检测保留周期方面的工作原理。 我有一个简单的父视图控制器和子视图控制器都持有彼此的引用。 在多次执行应用程序打开关闭 VC 后,当我打开调试工具时,它既没有显示保留周期问题也没有显示运行时问题。 请在下面找到代码示例和附加的xcode调试工具截图
class ViewController: UIViewController {
var child: ChildViewController?
@IBAction func open(_ sender: Any) {
performSegue(withIdentifier: "segueChild", sender: nil)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if (segue.identifier == "segueChild") {
child = segue.destination as? ChildViewController
child?.parentVC = self
}
}
}
class ChildViewController: UIViewController {
var parentVC: ViewController?
@IBAction func close(_ sender: Any) {
dismiss(animated: true, completion: nil)
}
}
【问题讨论】:
-
您找到答案了吗?我刚刚问了一个非常相似的问题。哈哈stackoverflow.com/questions/48988810/…
-
@Fogmeister No :),但它很棒,不仅仅是我 :D
标签: swift xcode memory-management memory-leaks retain-cycle