Posted By

Netzach on 03/12/09


Tagged

Objective-c NSTableView


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

Netzach
emoseman
avanadra


Basic NSTableView Control Functions


 / Published in: Objective C
 

  1. - (void) tableViewSelectionDidChange: (NSNotification *) notification{
  2. if ([tableView selectedRow] != -1) {
  3. NSString *string = [[array objectAtIndex:[tableView selectedRow]] value];
  4. // Do something
  5. }
  6. }
  7.  
  8. - (int) numberOfRowsInTableView:(NSTableView *)tableView{
  9. return [array count];
  10. }
  11.  
  12. - (id) tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex{
  13.  
  14. NSString *valueToDisplay = [[NSString alloc] init];
  15.  
  16. if (![[aTableColumn identifier] compare:@"Column 1"]) {
  17. valueToDisplay = [[array objectAtIndex:rowIndex] value1];
  18. }else if (![[aTableColumn identifier] compare:@"Column 2"]) {
  19. valueToDisplay = [[array objectAtIndex:rowIndex] value2];
  20. }else{
  21. valueToDisplay = @"ERROR!";
  22. }
  23.  
  24. return valueToDisplay;
  25. }

Report this snippet  

You need to login to post a comment.