Re: Implementing a record counter (record n of records)
Re: Implementing a record counter (record n of records)
- Subject: Re: Implementing a record counter (record n of records)
- From: Kevin Gessner <email@hidden>
- Date: Thu, 18 Dec 2008 15:39:35 -0500
On Dec 18, 2008, at 2:50 PM, Jon C. Munson II wrote:
Namaste!
I'm attempting to implement a simple record counter:
Record n of records
n = current record number
records = total number of records
I've looked at the Events Manager sample and borrowed the text field
from
there which has a representation of "# out #." It uses the Value with
Pattern Bindings method: %{value1}@ out of %{value2}@. value1 =
someController.selection.@count, value2 =
someController.arrangedObjects.@count.
However, the first binding, Value1, is incorrect. It holds the
number of
records that are selected (most likely used in conjunction with a
tableView). So, I changed it to selectedIndex instead of the
binding it
had. This, of course, yields a zero-based index value vs. count
which is
1-based. Then, the question after that is, what happens when there
aren't
any objects? selectionIndex is most likely going to be some number
other
than 0 (and it is from my own testing).
You could use a value transformer that would add 1 to selectedIndex.
It could also return something like "(nothing selected)" when there's
no selection. The "some number other than 0" might be
NSNoSelectionMarker, so you could check against that in your value
transformer.
HTH,
-- Kevin
Kevin Gessner
http://kevingessner.com
email@hidden
_______________________________________________
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