what is a bindings pattern to check for a non-empty selection?
what is a bindings pattern to check for a non-empty selection?
- Subject: what is a bindings pattern to check for a non-empty selection?
- From: Jean-Denis Muys <email@hidden>
- Date: Fri, 19 Feb 2010 12:02:36 +0100
Hello,
I have tried to search for an answer to that question, and I'm sure it must exist somewhere, but "bindings" and "select" or "selection" are definitely not specific enough.
I am looking for a way to enable a button in my window only if some selection has been made in the data. Currently the data is shown in a table view and is handled through an NSArrayController. I am trying to bind the button's "Enabled" property to the ArrayController so that I get whether something is selected (multiple selections allowed).
I have tried bindings to selectedObjects using the model key "count", as a non zero count is obviously compatible with the BOOL that the property expects. But this doesn't work: I get an error message:
"Cannot create BOOL from object () of class __NSArray0"
I really don't understand that error message, as the count message returns an integer, not an object. Can anybody explain?
I finally manage to use the "canRemove" key of the arrayController. It seems to work, but I feel nervous about it. I don't like the name of it. Of course at first glance, it seems you can't remove unless you have a non-empty selection, but other conditions may apply (not locked, whatever).
So is the "canRemove" the commonly accepted practice to test for a non empty selection in an table view using an NSArrayController?
Is there a reason for NSArrayController (or NSObjectController for that matter) not to have a "hasSelection" predicate available?
Or is there another better pattern?
(though the question is in the context of an table view and an NSArrayController, it might possibly be asked in a wider context).
Many thanks,
Jean-Denis
_______________________________________________
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