Skip to content

Instantly share code, notes, and snippets.

@francois
Created July 17, 2010 03:00
Show Gist options
  • Save francois/479199 to your computer and use it in GitHub Desktop.
Save francois/479199 to your computer and use it in GitHub Desktop.
NSTableView *documenstTable;
-(IBAction)changeDisplayedKey:(id)sender {
NSString *newValue = [[sender selectedItem] title];
NSTableColumn *column = [documentsTable tableColumnWithIdentifier:@"OID"];
/* Replace title: works just fine */
[[column headerCell] setStringValue:newValue];
/* Bind to the new keyPath */
/* data is an NSDictionary */
NSString *newKeyPath = [@"arrangedObjects.data." stringByAppendingString:newValue];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSRaisesForNotApplicableKeysBindingOption,
[NSNumber numberWithBool:YES], NSCreatesSortDescriptorBindingOption,
nil];
[[column dataCell] bind:@"value"
toObject:documentsArrayController
withKeyPath:newKeyPath
options:options];
[documentsTable reloadData];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment