NSWindowController circular dependency caused by bindings?

流过昼夜 提交于 2019-12-12 19:12:20

问题


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

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?

Do you know any common situation which may lead to similar circular dependencies?


回答1:


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

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.)



来源:https://stackoverflow.com/questions/1134914/nswindowcontroller-circular-dependency-caused-by-bindings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!