I need to change following properties for my NSTable View 1 -- Change Color:Row Color and Text Color when its selected 2 -- Change the Text Color , for each row it depends upon some input parameter,
For changing textcolor for each row, i should override delegate method willDisplayCell, This is what i have done , till now,
-- Creating the table ----
pMyTableView = [[[CustomTableView alloc] initWithFrame:clipViewBounds] autorelease];
NSTableColumn* firstColumn = [[[NSTableColumn alloc] initWithIdentifier:@"firstColumn"] autorelease];
[firstColumn setWidth:35];
[pMyTableView addTableColumn:firstColumn];
NSTableColumn* secondColumn = [[[NSTableColumn alloc] initWithIdentifier:@"secondColumn"] autorelease];
[secondColumn setWidth:180];
[pMyTableView addTableColumn:secondColumn];
[pMyTableView setRowHeight:30];
[self SetContactTableDisplayAttribute];
[pMyTableView setDataSource:self];
[scrollView setDocumentView:pOnLineCTView];
[pMyTableView setDelegate:self]
;
--- Other delegate Method -------------
- (id) tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex{
if([pColName isEqualToString:@"secondColumn"])
{
// Here there is some logic , to get the proper string that i wanted to display
return @"tempString";
}
}
---- Now this is how i am setting the text color ---
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex {
NSString *colName = [aTableColumn identifier];
if([colName isEqualToString:@"secondColumn"]){
NSTextFieldCell *pCell = aCell;
[pCell setTextColor:[NSColor blueColor]];
}
}
With the above code, its going to exception in the Log, i could see the line -[NSCell setTextColor:]: unrecognized selector sent to instance Looks like somewhere i need to set the text Field cell, but how and where i have no idea, kindly help me,
Another thing is, Initially i don't need any background for cell, but once when cell is selected , then also i might need to change the Background or you can say highlight color, can i get the same in WillDIsplayCell too