objective c - Can you manually implement Cocoa bindings? -
I have a crack in implementing bindings for my own NSView subclass. It works, but there are problems in maintaining the cycle when the owner of the files bind to the Nib file. After reading a little bit in it, I came to know that even a few years ago, Apple had a single problem, but decided it with some magic underdained class (NSAuthon Bender).
There is a long discussion of the cycle maintenance problem here. Window controller has been released , in the window-like place Delivered , before all binding is optional to close. It seems like an unnecessary hack for me.
My question is: Is there a way to do custom bindings that can be used without the help of documents created by Apple as well? Am I going wrong about this? Update 2: I have found a solution that allows manual binding to work like a binding of Apple. Without really using this undocumented features, the non-documentary NSAuthon Bundler takes advantage of the class I will post the solution later today.
UPDATE: I tried to use expose binding:
, and there is no difference between it . However, the implementation of NSObject
bind: toObject: with the path: option:
works in half it changes in binders (such as to view by model / controller) Suggests, but does not work in the opposite way. Apart from this, even though Bindi is being clearly seen, inspection valuefork: off object: change: context:
has never been triggered.
The example project is here:
Apple's documentation indicates that you do, in fact, bind: toObject: with the Cape Path: option:
Here's how to override the manual binding implementation:
Side note: I've checked how undocumented NSAutounbinder works, and here's what I know
< P> When a binding is designed for an NSWindowController, then the bound object is actually an NSUUT Nbainder which have been obtained with NSWindowController - [NSWindowController _autounbinder]. NSAutounbinder is a non-maintenanceal proxy for the NSWindowController object. It is non-maintenance to avoid the intact cycle problem.When - [NSWWoddoll Release] is called and maintained == 1, the NSUUtinBinder opens itself to all bindings. This ensures that there is no drop-down signal on the object before the object is dealt.
Here's the best solution I can find. I've got a more detailed discussion and demo code:
Actually, you not override bind: toObject: with capeth: option:
Or nickname:
. To avoid maintaining the default implementation cycle on NSObject
will use NSAutounbinder
as Lewis Gerberg pointed out, there are still situations where NSAuthBullBinder
Does not bring inside. However, you can work your bindings at least with the binding of the apple.
Due to the default implementation of:
- (zero) propagateValue: binding for (id) value: (NSString *) binding;
This bound object manages to achieve the bound path and implement the value transformer. The implementation is available on the link at the top.
Comments
Post a Comment