Skip to content

Instantly share code, notes, and snippets.

@zmalltalker
Created July 25, 2008 08:34
Show Gist options
  • Save zmalltalker/2414 to your computer and use it in GitHub Desktop.
Save zmalltalker/2414 to your computer and use it in GitHub Desktop.
#import "AppController.h"
#import "Person.h"
@implementation AppController
-(id)init
{
NSLog(@"Initializing");
people = [Person findAll];
return self;
}
-(int)numberOfRowsInTableView:(NSTableView *)tv
{
return [people count];
}
-(id)tableView:(NSTableView *)tv
objectValueForTableColumn:(NSTableColumn *)tableColumn
row:(int)row
{
Person *currentPerson = [people objectAtIndex:row];
return [currentPerson valueForKey:[tableColumn identifier]];
}
-(void)tableViewSelectionDidChange:(NSNotification *)notification
{
NSLog(@"Selection changed");
int row = [tableView selectedRow];
if (row == -1)
{
return;
}
Person *currentPerson = [people objectAtIndex:row];
NSString *bio = [currentPerson valueForKey:@"bio"];
[detailView setStringValue:bio];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment