Basic NSTableView Control Functions


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.