Re: NSTableView text color question
Re: NSTableView text color question
- Subject: Re: NSTableView text color question
- From: Mike Brinkman <email@hidden>
- Date: Wed, 01 Oct 2003 14:03:17 -0400
Eureka, that works! Viel Dank Andreas! You are a kind and generous soul!
On 10/1/03 10:07 AM, "Andreas Mayer" <email@hidden> wrote:
>
Am Mittwoch, 01.10.03 um 14:18 Uhr schrieb Mike Brinkman:
>
>
> Could somebody PLEASE either provide a link to a sample that does
>
> this, or simply tell me the exact 2 or 3 lines of code that I need to
>
> make
>
> this work?
>
>
What about
>
>
- (void)tableView: (NSTableView *)aTableView willDisplayCell: (id)aCell
>
forTableColumn: (NSTableColumn *)aTableColumn row: (int)aRowIndex
>
{
>
if ([[aTableView delegate] itemIsDueForRow:aRowIndex]) {
>
[aCell setTextColor:[NSColor redColor]];
>
} else {
>
[aCell setTextColor:[NSColor blackColor]];
>
}
>
}
>
>
Now you'll have to implement itemIsDueForRow: for your table view
>
delegate:
>
>
- (BOOL)itemIsDueForRow:(int)aRowIndex
>
{
>
NSTimeInterval secondsLeft = [[[toDo objectAtIndex:aRowIndex] dueDate]
>
timeIntervalSinceNow];
>
return ((secondsLeft/86400) < 7);
>
}
>
>
This assumes that a to do item responds to dueDate with its due date
>
(doh!) in form of an NSDate object.
>
>
Oh. And you might want to cast the [aTableView delegate] to the actual
>
class of your delegate to get rid of the compiler warning, like
>
>
if ([(MyDelegateClass *)[aTableView delegate]
>
itemIsDueForRow:aRowIndex]) {
>
>
>
bye. Andreas.
>
_______________________________________________
>
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.
_______________________________________________
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.