Re: what is a bindings pattern to check for a non-empty selection?
Re: what is a bindings pattern to check for a non-empty selection?
- Subject: Re: what is a bindings pattern to check for a non-empty selection?
- From: Steven Degutis <email@hidden>
- Date: Fri, 19 Feb 2010 08:44:07 -0500
I too have been wondering how others approach this issue. For a long time I
used "canRemove" and eventually switched to using my own value transformer
which does the heavy lifting for me. But it's quite tedious to include this
value transformer in every project I write which uses bindings like this, so
I've been looking for a "built-in" alternative. So now I'm wondering if
"selectedObjects.@count" is a good alternative. Have yet to try it, but it
looks viable.
-Steven
On Fri, Feb 19, 2010 at 8:27 AM, Ken Thomases <email@hidden> wrote:
> On Feb 19, 2010, at 7:15 AM, Jerry Krinock wrote:
>
> > On 2010 Feb 19, at 03:02, Jean-Denis Muys wrote:
> >
> >> 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"
> >
> > It means that it wants a BOOL but the selectedObjects you're giving it is
> an array.
>
> Did you try the @count KVC operator?
>
> http://developer.apple.com/mac/library/documentation/cocoa/conceptual/KeyValueCoding/Concepts/ArrayOperators.html
>
> Using the model key "count" to an array property (selectedObjects) builds a
> new array containing the results of invoking valueForKey:@"count" to each
> element of selectedObjects, which isn't what you meant.
>
> Regards,
> Ken
>
> _______________________________________________
>
> 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
>
--
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.org/
_______________________________________________
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