Re: Bidirectional, Manual Binding in custom control
Re: Bidirectional, Manual Binding in custom control
- Subject: Re: Bidirectional, Manual Binding in custom control
- From: Jerry Krinock <email@hidden>
- Date: Tue, 22 May 2012 06:12:58 -0700
On 2012 May 21, at 21:52, Quincey Morris wrote:
> This seems more or less the correct approach to defining a custom binding. "More or less" because you may have committed some minor technical violation of custom binding implementations, described unintelligibly in this document:
>
> https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaBindings/Concepts/HowDoBindingsWork.html
>
> However, it's not particularly clear what benefit it brings you to implement a custom binding, since there's no practical way any more (AFAIK) to use custom bindings in IB.
Thank you, Quincey. Yes, I know about that – arghhh – IB limitation. That's why I -bind:::: in the window controller's -awakeFromNib.
> With a code-based approach, it may be easier and clearer just to implement the two halves of the behavior directly:
Yes, I see what you mean. This may be one of those cases where Cocoa Bindings makes life more difficult instead of easier.
In this case, I kind of like the binding though, because all of the other fields in this Inspector window use bindings, and I'd rather not break the pattern. I'll read "How Do Bindings Work" and see if I can find any "technical violations".
Jerry
(For sake of list archives, for anyone else who wants to try this, there's an important detail I left out of my original post. Remember to -unbind: in the window controller's -windowWillClose or -dealloc, or you'll get exceptions and/or crashes. I do it in both methods, calling a method which also removes other observers. I use an instance variable, m_isObserving, to keep track of whether or not my bindings and observers are active.)
_______________________________________________
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