Created
June 9, 2011 00:37
-
-
Save OneSadCookie/1015790 to your computer and use it in GitHub Desktop.
Uglyfugly table view code
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
// TODO use bindings for this, once I figure out the data model... | |
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView | |
{ | |
return [[[self document] attributes] count]; | |
} | |
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row | |
{ | |
assert(tableView == attributeTable); | |
OBAttribute *attribute = [[[self document] attributes] objectAtIndex:row]; | |
if ([[tableColumn identifier] isEqualToString:@"attribute"]) | |
{ | |
return [attribute description]; | |
} | |
else if ([[tableColumn identifier] isEqualToString:@"binding"]) | |
{ | |
NSString *identifier = [[[self document] attributeBindings] objectForKey:[attribute name]]; | |
return [NSNumber numberWithUnsignedInt:[[tableColumn dataCell] indexOfItemWithTitle:identifier]]; | |
} | |
else | |
{ | |
abort(); | |
} | |
} | |
- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row | |
{ | |
assert(tableView == attributeTable); | |
NSString *attributeName = [[[[self document] attributes] objectAtIndex:row] name]; | |
assert([[tableColumn identifier] isEqualToString:@"binding"]); | |
assert([object isKindOfClass:[NSNumber class]]); | |
NSString *title = [[tableColumn dataCell] itemTitleAtIndex:[object unsignedIntValue]]; | |
[[[self document] attributeBindings] setObject:title forKey:attributeName]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment