• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Implementing a record counter (record n of records)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • RE: Implementing a record counter (record n of records)
      • From: "Jon C. Munson II" <email@hidden>
References: 
 >Implementing a record counter (record n of records) (From: "Jon C. Munson II" <email@hidden>)

  • Prev by Date: Re: Enabling add button
  • Next by Date: Re: Enabling add button
  • Previous by thread: Implementing a record counter (record n of records)
  • Next by thread: RE: Implementing a record counter (record n of records)
  • Index(es):
    • Date
    • Thread