NSWindowController循环依赖引起的绑定? [英] NSWindowController circular dependency caused by bindings?

查看:175
本文介绍了NSWindowController循环依赖引起的绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您有一个窗口nib,由一个装载nib的NSWindowController拥有。

Suppose you have a window nib, owned by a NSWindowController which loads the nib.

NSWindowController有一个IBOutlet(通过Interface Builder)绑定到窗口上的UI控件。

The NSWindowController has an IBOutlet bound (via Interface Builder) to a UI control on the window.

真的,你不能通过释放它来处置窗口控制器,因为绑定导致窗口控制器和控件之间的一个不可破坏的循环依赖?

Is it true that you can't dispose the window controller by releasing it because the binding causes a unbreakable circular dependency between the window controller and the control?

你知道任何常见的

推荐答案

在这种情况下,编写一个聚焦的示例应用程序,调试器是理解操作方式的好方法。

In situations like this, writing a focused sample application, and observing execution in the debugger is a great way to understand how things work.

只需通过文件所有者绑定就不会导致保留周期(10.4和更高版本)。 NSWindowController(和NSViewController)采取措施避免这个问题。

Simply binding through File's Owner should not cause retain cycles (on 10.4 and later). NSWindowController (and NSViewController) take steps to avoid this problem.

如果你遇到一个情况,你的绑定导致保留周期,有策略来避免它们。 (具体设置的详细信息可能需要具体建议。)

If you do run into a situation where your bindings are causing retain cycles, there are strategies to avoid them. (Further details for your specific setup is probably necessary to over specific advice.)

这篇关于NSWindowController循环依赖引起的绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆