Re: Another Bindings problem - sorry!
Re: Another Bindings problem - sorry!
- Subject: Re: Another Bindings problem - sorry!
- From: Miguel Sanchez <email@hidden>
- Date: Mon, 6 Mar 2006 18:13:32 -0800
it sounds to me like you're missing the CONTROLLER part in the MODEL-
VIEW-CONTROLLER paradigm (check doc on this).
You seem to be allowing your data objects to directly own the
interface that displays them. The right approach for this is to have a
controller object (nothing related to bindings controllers) that is
the intermediary between the model objects (MyMinObject) and the UI.
The controller would also be the file owner in you nib.
I recommend you review the Model-View-Controller docs and a bindings
example that sets up master detail relationships.
- Miguel
On Mar 6, 2006, at 5:05 PM, Mike Abdullah wrote:
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
_______________________________________________
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