• 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: NSTableView text color question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView text color question


  • Subject: Re: NSTableView text color question
  • From: Andreas Mayer <email@hidden>
  • Date: Wed, 1 Oct 2003 16:07:00 +0200

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.

  • Follow-Ups:
    • Re: NSTableView text color question
      • From: Mike Brinkman <email@hidden>
References: 
 >Re: NSTableView text color question (From: Mike Brinkman <email@hidden>)

  • Prev by Date: Reading The Text of PDF files
  • Next by Date: NSURL Query
  • Previous by thread: Re: NSTableView text color question
  • Next by thread: Re: NSTableView text color question
  • Index(es):
    • Date
    • Thread