我有 NSOutlineView 和名为 ListCell 的自定义单元格。我将标签和图标设置为我的自定义单元格。然后 NSOutlineView 在错误 exc_bad_access code=13 上崩溃。你有什么想法,如何修复它?谢谢回复。
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
return [[[DataSingleton sharedData] pages] count];
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
return NO;
}
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item {
return item;
}
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item {
ListTableCellView *cell = [outlineView makeViewWithIdentifier:@"ListCell" owner:self];
cell.label.stringValue = [NSString stringWithFormat:@"%ld", index + 1];
[cell.label setBackgroundColor:[NSColor clearColor]];
if ([self.icons objectForKey:[NSString stringWithFormat:@"%ld", index]])
[[cell icon] setImage:[self.icons objectForKey:[NSString stringWithFormat:@"%ld", index]]];
return cell;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item {
return YES;
}