Skip to content

Instantly share code, notes, and snippets.

@Me1000
Created November 1, 2009 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Me1000/223410 to your computer and use it in GitHub Desktop.
Save Me1000/223410 to your computer and use it in GitHub Desktop.
/*the table delegate method*/
- (id)tableView:(CPTableView)tableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(int)row
{
if(row % 2)
{
return {"text": row, "color":"000000"}
}
else
{
return {"text":row, "color":"FFFFFF"}
}
}
/*The tableview cell*/
@implementation aCustomTableCell : CPView
{
CPTextField text;
}
- (id)init
{
self = [super init];
if(self)
{
text = [[CPTextField alloc] initWithFrame:CGRectMake(0,0,150,24)];
[self addSubview:text];
}
return self;
}
- (void)setObjectValue:(id)values
{
// "values" is a JSON object.
[text setFontColor:[CPColor colorWithHexString:values.color]];
[text setStringValue:values.text];
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
[aCoder encodeObject:text forKey:@"text"];
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
if(self)
{
text = [aCoder decodeObjectForKey:@"text"];
}
return self;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment