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 %{valu...@.  value1 =
somecontroller.selecti...@count, value2 =
somecontroller.arrangedobjec...@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
ke...@kevingessner.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to