Re: ObjectController preventing WindowController from releasing
Re: ObjectController preventing WindowController from releasing
- Subject: Re: ObjectController preventing WindowController from releasing
- From: Jonathan Taylor <email@hidden>
- Date: Mon, 07 Nov 2011 17:16:14 +0000
Hi Ken,
Thanks very much for your reply!
>> I have a window and window controller which in the absence of an object controller work fine, and both are deallocated when the window is closed. If I add an ObjectController to the NIB and bind its "Content Object" to "File's Owner.self" then the window no longer closes properly.
>
> What is the File's Owner? Is the window controller the file's owner?
Yes, the window controller is the file's owner, bound to the window, and with the window controller set up to be the delegate for the window.
> Is the window controller the one loading the NIB (rather than, say, using NSBundle or NSNib directly)? NSWindowController has some built-in functionality to break retain cycles for binding through File's Owner when and only when it is the File's Owner and loads the NIB.
Yes it loads the nib from its own init routine, via initWithWindowNibName
> What would you sensibly bind to the File's Owner itself, rather than one of its properties? In other words, what is bound to or through the object controller?
OK, I am not absolutely sure I've understood what you're getting at here, but I will try and answer in two parts - firstly what I originally did, and still do for a number of other windows, followed by the exact situation for this window. It may be that I am doing something wrong in either or both of these, but it may help explain how I've ended up where I have.
== What I originally did ==
The "Content Object" of the ObjectController is bound to "File's Owner.self" and various GUI text boxes are bound to variables within the file's owner e.g. a text box bound to Object Controller.selection.speed. Rightly or wrongly, the data model is contained within the window controller - it really didn't seem worth the effort of separating them out.
Assuming I have set everything up correctly, this was originally suggested to me by a poster on here in order that I could make calls to [myObjectController commitEditing] when I needed to.
== The actual situation for this window ==
I'm not sure if this is what you are getting at here, but actually in this specific case there IS a separation between window controller and data model. The window controller is a very lightweight class which keeps a pointer to the object "camera" that actually contains the data model. So the text boxes are actually bound to things like Object Controller.selection.camera.framerate. Are you suggesting that this could be the problem and I should be binding the Object Controller to File's Owner.camera instead of to File's Owner.self, and that this might help break retain cycles?_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden