• 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: Color/Number List
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Color/Number List


  • Subject: Re: Color/Number List
  • From: "Joshua D. Orr" <email@hidden>
  • Date: Thu, 26 Jul 2001 22:56:42 -0600

It does not appear to work, the cells do not change to the correct color (but the numbers do get displayed). Does anyone have any idea what's wrong?

On Wednesday, July 25, 2001, at 08:49 PM, Tom Waters wrote:

On Wednesday, July 25, 2001, at 04:26 PM, Joshua D. Orr wrote:

I have a list (actually an array) of NSNumber's and NSColor's. The colors
correspond to the numbers. I want to be able to somehow display these in a
list (like a table). I am thinking about using a table and set the textview
cells with the number, and somehow set the background color of the textview
cells to the corresponding colors.

Is there someway to do this (I have been looking though the documentation,
but have not found a way to do this), or is there some better way to do
this?

This is written in email and not tested... but it should point you in the right direction.

assumes that your arrays are allocated and filled somewhere else...
it also assumes you have one column in your table and that that columns dataCell prototype is an NSTextFieldCell
and that you've set the instance of MyDelegate as the table's dataSource and delegate in IB.


@interface MyDelegate : NSObject
{
NSArray *numbers;
NSArray *colors;
}
@end

@implementation MyDelegate
- (void)tableView:(NSTableView *)view
willDisplayCell:(id)cell
forTableColumn:(NSTableColumn *)col
row:(int)row
{
[cell setBackgroundColor: [colors objectAtIndex:row]];
}

- (int)numberOfRowsInTableView:(NSTableView *)view
{
return [numbers count];
}

- (id)tableView:(NSTableView *)view
objectValueForTableColumn:(NSTableColumn *)col
row:(int)row
{
return [numbers objectAtIndex:row];
}
@end
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


  • Follow-Ups:
    • Re: Color/Number List
      • From: Tom Waters <email@hidden>
References: 
 >Re: Color/Number List (From: Tom Waters <email@hidden>)

  • Prev by Date: Re: why does the method popup sometimes not appear in PB ?
  • Next by Date: Any way to change the view hierarchy after the fact in IB?
  • Previous by thread: Re: Color/Number List
  • Next by thread: Re: Color/Number List
  • Index(es):
    • Date
    • Thread