Re: Line Numbers in Tables
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