问题
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