Okay, in a project I'm working on, I made the mistake of trying to do
something simple with the weird deep magic known as Cocoa Bindings.
I've got two classes - let's call them "Foo" and "Bar". Foo's
implementation has this in it:
Foo and Bar are both instantiated in Interface Builder, and Foo has an
outlet to Bar. There's also an NSObjectController that's got its
content outlet pointed at Foo. Foo has an outlet called
"ivar_controller" that points to that NSObjectController. Foo's also
got a method that returns its Bar outlet:
- (Bar *)bar {
return ivar_bar;
}
and in Foo's windowControllerDidLoadNib: method (it's an NSDocument
subclass) I've got this:
Now here's the thing: if I call setDisplayName: on Foo, it calls Bar's
setTitle: method, exactly as it should. However, if I call setTitle:
on Bar, it does *not* end up calling Foo's setDisplayName: method,
although it seems like it should. I can change the
bind:toObject:withKeyPath:options: invocation above so that it binds
Bar directly to Foo without going through the object controller, or I
can try going the other way and binding the Foo to the Bar - always I
get the same result.