0

ListCellという名前のカスタムセルを持つNSOutlineViewがあります。カスタムセルにラベルとアイコンを設定しました。次に、エラー exc_bad_access code=13 で NSOutlineView がクラッシュします。それを修復する方法はありますか?お返事Thxです。

- (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;
}
4

2 に答える 2

-4

単に NSOutlineView を NSTableView に変更しただけで、すべて問題ありません。

于 2013-05-14T17:46:45.043 に答える