NSTableView and custom NSTableColumn subclass crash
NSTableView and custom NSTableColumn subclass crash
- Subject: NSTableView and custom NSTableColumn subclass crash
- From: Matt Handley <email@hidden>
- Date: Sun, 10 Nov 2002 18:48:56 -0600
For some reason, my subclass of NSTableColumn crashes!
When I run the code below, my window opens properly. However, as soon
as I either click on the header cell, or as soon as I add a row, the
program crashes with a SIGSEGV or SIGBUS error. When I debug the code,
and I tell the table view to print out a description of the table
columns, I get this error if I'm not in awakeFromNib:
Program received signal EXC_BAD_ACCESS, Could not access memory.
0x9068ba54 in objc_msgSend ().
The column subclass is hooked up to the table through IB, using the
Custom Class pane of the inspector.
The subclass itself is amazingly simple. I'm not sure why it doesn't
work!
In AppController.m:
- (void)awakeFromNib
{
NSLog([[tableView tableColumnWithIdentifier:@"dummy"] description]);
NSLog([[[tableView tableColumnWithIdentifier:@"dummy"] dataCell]
description]);
NSLog([[[tableView tableColumnWithIdentifier:@"dummy"]
dataCellForRow:0] description]);
NSLog([[[tableView tableColumnWithIdentifier:@"dummy"]
dataCellForRow:1] description]);
NSLog([[[tableView tableColumnWithIdentifier:@"dummy"] tableView]
description]);
NSLog([[NSNumber numberWithInt:[[tableView
tableColumnWithIdentifier:@"dummy"] width]] stringValue]);
NSLog([[[tableView tableColumnWithIdentifier:@"dummy"] headerCell]
description]);
}
prints out:
2002-11-10 18:32:02.373 ImageTableTest[1657] <ImageAndTextColumn:
0xb00e0>
2002-11-10 18:32:02.377 ImageTableTest[1657] <NSTextFieldCell: 0x225270>
2002-11-10 18:32:02.378 ImageTableTest[1657] <NSImageCell: 0x24c7c0>
2002-11-10 18:32:37.393 ImageTableTest[1657] <NSTextFieldCell: 0x24cb90>
2002-11-10 18:32:37.394 ImageTableTest[1657] <NSTableView: 0x21e2b0>
2002-11-10 18:32:37.395 ImageTableTest[1657] 420
2002-11-10 18:32:37.395 ImageTableTest[1657] <NSTableHeaderCell:
0x220ca0>
So that I know that the table column works...However when I call my
addRow action:
- (IBAction)addRow:(id)sender
{
[mapList addObject:[NSImage imageNamed:@"HLineBrushShape.gif"]];
[mapList addObject:@"This is the first line of text"];
NSLog([[tableView tableColumnWithIdentifier:@"dummy"] description]);
NSLog([[[tableView tableColumnWithIdentifier:@"dummy"] dataCell]
description]);
NSLog([[[tableView tableColumnWithIdentifier:@"dummy"]
dataCellForRow:0] description]);
NSLog([[[tableView tableColumnWithIdentifier:@"dummy"]
dataCellForRow:1] description]);
NSLog([[[tableView tableColumnWithIdentifier:@"dummy"] tableView]
description]);
NSLog([[NSNumber numberWithInt:[[tableView
tableColumnWithIdentifier:@"dummy"] width]] stringValue]);
NSLog([[[tableView tableColumnWithIdentifier:@"dummy"] headerCell]
description]);
[tableView reloadData];
}
the first NSLog gives a EXC_BAD_ACCESS error. What gives? Is my setup
for my NSTableColumn wrong:
@implementation ImageAndTextColumn
- (id)dataCellForRow:(int)row
{
if (row % 2)
return [[NSTextFieldCell alloc] initTextCell:@""];
else
return [[NSImageCell alloc] initImageCell:nil];
}
@end
I realize this will burn through memory, but this is just a test app
which is supposed to test this whole custom column idea.
Matt Handley
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.