I have an NSTableView
with a single column. This column has "Editable" checked in Interface Builder, but double-clicking on a cell in the table view does nothing. I've confirmed (in -tableView:viewForTableColumn:row:
by checking [tableColumn isEditable]
) that the table column has the editable flag set. What would prevent the column from being editing if isEditable == YES
?
It's been suggested that I include my datasource and delegate code. The dataArray
is a property that stores NSManagedObject
subclass objects. listPopupButton
selects which entity to be viewing in an NSTableView
that can display different entities, all of which have only a name attribute (as indicated by the nameOnlyItems
method that returns an array of these).
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
return [[self dataArray] count];
}
- (NSView *)tableView:(NSTableView *)tableView
viewForTableColumn:(NSTableColumn *)tableColumn
row:(NSInteger)row {
NSTableCellView *cellView;
NSNumber *index = [NSNumber numberWithInteger:[[self listPopupButton] indexOfSelectedItem]];
if ([[self nameOnlyItems] containsObject:index]) {
CVCAbstractEntity *entity = [[self dataArray] objectAtIndex:row];
NSString *name = [entity name];
cellView = [tableView makeViewWithIdentifier:@"nameOnly" owner:self];
[[cellView textField] setStringValue:name];
} else if ([index integerValue] == CVCListPopUpIndexPublishers) {
CVCPublisher *publisher = [[self dataArray] objectAtIndex:row];
NSString *identifier = [tableColumn identifier];
NSString *content;
content = [[publisher valueForKeyPath:identifier] description];
if ([identifier containsString:@"year"] && [content isEqualToString:@"0"]) {
content = @"";
}
cellView = [tableView makeViewWithIdentifier:identifier owner:self];
[[cellView textField] setStringValue:content ? content : @""];
} else if ([index integerValue] == CVCListPopUpIndexSeries) {
CVCSeries *series = [[self dataArray] objectAtIndex:row];
NSString *identifier = [tableColumn identifier];
NSString *content;
content = [[series valueForKeyPath:identifier] description];
if ([identifier containsString:@"year"] && [content isEqualToString:@"0"]) {
content = @"";
}
cellView = [tableView makeViewWithIdentifier:identifier owner:self];
[[cellView textField] setStringValue:content ? content : @""];
}
return cellView;
}
- (void)tableView:(NSTableView *)tableView sortDescriptorsDidChange:(NSArray *)oldDescriptors {
NSMutableArray *mutableDataArray = [[self dataArray] mutableCopy];
[mutableDataArray sortUsingDescriptors:[tableView sortDescriptors]];
[self setDataArray:mutableDataArray];
[[self nameOnlyTableView] reloadData];
}