• 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: Line Numbers in Tables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Line Numbers in Tables


  • Subject: Re: Line Numbers in Tables
  • From: Antonio Nunes <email@hidden>
  • Date: Thu, 30 Aug 2007 13:38:11 +0100

On 30 Aug 2007, at 12:48, Chris Suter wrote:

1. Create an NSTableView subclass:

@interface ANLineNumberTableView : NSTableView {
	unsigned _lineNumber;
}

- (unsigned)lineNumber;

@end

@implementation ANLineNumberTableView

- (unsigned)lineNumber
{
unsigned result = ++_lineNumber; // increment each time we are asked, which is once per row
if (_lineNumber == [self numberOfRows]) // when at the last row we ned to reset the line number
_lineNumber = 0;
return result;
}


@end

2. Bind the desired table view's column to its table view's lineNumber property.

I created a little test project and it works a treat. The project also shows how to sort numbers in strings numerically (rather then alphabetically). To find the project take a break here: http:// web.mac.com/antonionunes/

If this latest code still is offensive do let me know. :-)

This approach doesn't look good to me. You're relying on an implementation detail that may change in future and it wouldn't surprise me if there were some circumstances where the approach above doesn't work.

Fair enough. The latter had occurred to me, but I couldn't think offhand of an occasion where this would fail. Can you?
As for relying on an implementation detail that may change: do you mean trusting that the column will get each cell's contents sequentially starting from the first row? If so, I guess you're right. Sigh. Not sturdy enough. My bad.


All right then. No more trying to use bindings to get the row number of a table column. Back to data sources.

Cheers,
António

----------------------------------------------------
The is nothing as strong as real gentleness, and
there is nothing as gentle as real strength.
----------------------------------------------------



_______________________________________________

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


References: 
 >Line Numbers in Tables (From: Gordon Apple <email@hidden>)
 >Re: Line Numbers in Tables (From: Antonio Nunes <email@hidden>)
 >Re: Line Numbers in Tables (From: mmalc crawford <email@hidden>)
 >Re: Line Numbers in Tables (From: Antonio Nunes <email@hidden>)
 >Re: Line Numbers in Tables (From: Antonio Nunes <email@hidden>)
 >Re: Line Numbers in Tables (From: Chris Suter <email@hidden>)

  • Prev by Date: Re: Line Numbers in Tables
  • Next by Date: Re: How to create .widgetplugin with java source file??
  • Previous by thread: Re: Line Numbers in Tables
  • Next by thread: Re: Line Numbers in Tables
  • Index(es):
    • Date
    • Thread