On Mar 25, 2011, at 6:22 PM, Quincey Morris wrote: > On Mar 25, 2011, at 18:01, Rick Mann wrote: > >> Part of the problem I had was that I don't have indices readily available. I >> have the objects themselves, and I could look them up in the array, but that >> strikes me as potentially slow (for a lot of objects). > > There's always -[NSArrayController setSelectedObjects], though using that > might just drive the work involved in deriving selection indexes inside > NSArrayController, where you can't even control the performance. > > But the point is that the underlying mechanism is all in NSArrayController's > documented API, and you should be reading that.
OK. Truth is, there are so many slightly different ways to get & set the selection in object controllers, and while I've been able to mimic examples to get things to work, I really don't understand them well, despite having read the docs. Frankly, I think the docs are inadequate. Could be because of assumptions I'm implicitly making about how I'd expect them to behave. But with what you've told me, now I know what to at least try to do. > >> I think there's a typo there, so I'm not quite sure what you're telling me. >> In fact, I will eventually have both a custom control in the inspector, and >> the view in which the selection is managed by the user is custom. > > Yes, it was a typo. I meant: > >> "you aren't going to want to do this with bindings, not when the selection >> is controlled from a custom view" > > For a custom view, that is, where the behavior of the view is enshrined in > code you write, there's absolutely no value in using bindings, and creating a > bindings mechanism for that view is wasted work. > > Bindings are for UI elements (and similar stuff) that are reused in many > contexts, so that they can be configurable in IB without additional coding. > Your custom view is being used in one context (presumably, more or less), and > you're coding its behavior anyway. > > Putting this another way, bindings are (in use) a kind of code-free extension > of the KVO mechanism (addObserver... and observeValue...). If you're coding > anyway, it's cheaper and easier to use KVO directly. > > That was the point I was trying to make. Gotcha. Well, in this case, my inspectors are made up of many different standard widgets, and for them I really do want to use bindings. Moreover, the objects that might be selected can be provided by plug-ins to my app. But I get what you're saying, and my custom control may not merit bindings of its own. Thanks! _______________________________________________ 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]
