Created
November 1, 2009 06:00
-
-
Save Me1000/223410 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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