Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Line Numbers in Tables




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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

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>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.