Re: Displaying a table entry in Bold
Re: Displaying a table entry in Bold
- Subject: Re: Displaying a table entry in Bold
- From: Ondra Cada <email@hidden>
- Date: Fri, 19 Apr 2002 21:28:17 +0200
On Friday, April 19, 2002, at 09:14 , Joe Morris wrote:
NSString *string = [self tableView:sender
objectValueForTableColumn:column row:row];
NSAttributedString *attrStr = [ [ [NSAttributedString alloc]
initWithString:string attributes:txtDict] autorelease];
[cell setAttributedStringValue:attrStr];
}
This is with the self object being set up as the tableView's delegate and
data source (both by dragging connections in Interface Builder). The
beauty of this function is you don't even have to delve into getting what
the cell should display text-wise, you can just use the function you've
already implemented for that very purpose. :-)
Actually, to be really independent you would have to check whether there
is a formatter and, if so, use it to translate the "string" of yours to
real string. Even without a formatter this won't work properly eg. if the
objectValueForTableColumn:row: happens to be say an NSNumber, which is
quite possible generally.
The proper way to do that (in cases like this when you want the whole cell'
s format to be unique) is not to play with attributed strings at all, and
just to set cell's attributes directly. Then let it to display the data
itself: why to re-write an already existing code?
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.