• 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: Chris Suter <email@hidden>
  • Date: Thu, 30 Aug 2007 21:48:16 +1000


On 30/08/2007, at 9:14 PM, Antonio Nunes wrote:

The following however will show proper line numbers:

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.


- Chris

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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: Line Numbers in Tables
      • From: Antonio Nunes <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>)

  • Prev by Date: Re: Line Numbers in Tables
  • Next by Date: Re: Line Numbers in Tables
  • Previous by thread: Re: Line Numbers in Tables
  • Next by thread: Re: Line Numbers in Tables
  • Index(es):
    • Date
    • Thread