I m trying to implement my own version of NSViewController (for backwards compatibility), and I ve hit a problem with bindings: Since bindings retain their target, I have a retain circle whenever I bind through File s owner.
So I thought I d just explicitly remove my view from its superview and release the top level objects, and that would take care of the bindings, because my controller isn t holding on to the views anymore, so they release me and I can go away. But for some reason, my view controller still doesn t get released. Here s a sample app exhibiting the problem:
http://dl.dropbox.com/u/34351/BindingsLeak.zip
Build it, launch it, and hit Cmd-K ("Create Nib" in "Edit" menu) to load a NIB into the empty window. Hit Cmd-K again to release the first view controller (TestNibOwner) and load a new one. The old view controller never gets dealloced, though.
Remove the "value" binding on the checkbox, and it gets released just fine.
If you set breakpoints at the release/retain/autorelease overrides, you see that _NSBindingInfo retains the TestNibOwner, but never releases it in the leaking case.
Anyone know how to fix this?