On Jan 28, 2010, at 11:12, Richard Somers wrote:
> Actually that is about all there is (and it works except for the leak). I
> started with Malcolm Crawford's "Graphics Bindings" example. It is the most
> complex programmatic example he has but just so happened to be the one that
> fit my need. I got hopelessly lost trying to understand the code and just
> started tossing things until I got down to a level that I could start to
> comprehend what was going on.
>
> http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
But you did nothing like what's in that example. It defines (and exposes) 2
named bindings of the custom view object, and implements all of the behavior
associated with each binding. The [bind:...] implementation is just one piece
of the whole. As it happens (whether by accident or design isn't clear), you
can pass a property name as the first parameter instead of a true binding name,
and you'll end up with a uni-directional "binding" (as if you observed the
bound-to property and updated the bound-from property whenever it changes).
This may be sufficiently functional for your current project, but it's not
really a binding, and it's not at all obvious that this behavior will continue
to exist.
> Programmatic bindings can be simplified. For example refer to "Implementing
> Your Own Cocoa Bindings" by Tom Dalling.
>
> www.tomdalling.com/cocoa/implementing-your-own-cocoa-bindings
That blog clearly states that [bind:...] is only half of the behavior of a
binding.
> Any way it is true that "array" is an instance variable of the CustomObject
> which is bound to a NSArrayController.
>
> The purpose of the binding is to iterate over arrangedObjects like this.
>
> for (id foo in array) {
> // each foo do your thing
> }
What's wrong with:
for (id foo in arrayController.arrangedObjects)
...
? After all, "arrangedObjects" is documented to be an array. (It's actually a
kind of proxy, but it has the behavior of an array.)
> Also the "arrangedObjects.changed" observation of each foo does work.
In general, you can't observe an array (though you can observe an array
property of an arbitrary object), and KVC conventions make
"arrangedObjects.changed" be a reference to an array. Presumably it works
because there is something special about the "arrangedObjects" proxy, but
there's not guarantee of this behavior AFAIK.
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]