Another Bindings problem - sorry!
Another Bindings problem - sorry!
- Subject: Another Bindings problem - sorry!
- From: Mike Abdullah <email@hidden>
- Date: Tue, 7 Mar 2006 01:05:29 +0000
Hey, I'm really sorry, but I have another bindings problem. My app
has a slightly odd structure:
The document, has a MyMainObject instance in it.
An NSObjectController uses MyMainObject as it's content.
MyObject has an NSArray of the type MyMiniObject as one of its keys
This is managed by an NSArrayController
So, my app quite happily creates and destroys MyMiniObjects in
response to buttons in the interface.
However, I have now added a nib file to the project that is owned by
MyMiniObject. So every time MyMiniObject is initialized it loads
this nib and displays the view from the nib. When deallocing,
MyMiniObject releases the view
Now this view contains a text field. I want to bind the value of
this text field to a key of MyMiniObject. I have tried doing this by
both binding directly to the File's Owner, and by creating an
NSObjectController in the nib.
This binding works great until the NSArrayController attempts to
release MyMiniObject. MyMiniObject will no longer deallocate because
it is being retained by the text field binding. And so, dealloc of
MyMiniObject is never called, and so none of the related items are
released either!
Does anyone know how to implement this sort of relationship? At the
moment the best I can think of is to override release of
MyMiniObject. When release is called, I'd check to see what the
retain count is, and if it's only 1, I release the binding, thereby
deallocing MyMiniObject.
However, to me this seems a bit of an ugly workaround. Is it the
only option?
Mike A.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden