RE: Problem with dynamic reconfiguration of a TableView?
RE: Problem with dynamic reconfiguration of a TableView?
- Subject: RE: Problem with dynamic reconfiguration of a TableView?
- From: "Jonathan E. Jackel" <email@hidden>
- Date: Fri, 8 Nov 2002 10:36:30 -0500
>
I am writing a small application that reads a data file, it then
>
determines
>
the number of columns to add to a tableview, builds a represention of the
>
file and then adds the columns to a table view that was created with no
>
columns.
The first time this code is called there are no table columns, so the for
loop never happens. This is a big clue.
What the heck is tmpArray? Don't you mean colArray?
Not that this is your problem, but a while loop seems like a better solution
here. I haven't tested it, but something like this should work:
while ([[tableView tableColumns] count])
[tableView removeTableColumn:[[tableView tableColumns] objectAtIndex:0]];
This brings up one of my pet peeves. Does anyone else think it's strange
that you cannot obtain a reference to a table column by supplying the index
number of the column to the table view? Something like (NSTableColumn
*)[tableView columnAtIndex:x];? A lot of the table view methods return or
require an index number of a column (removeTableColumn:,
moveColumn:toColumn:, selectedColumn, selectColumn:byExtendingSelection:,
etc.).
Jonathan
>
Hi,
>
>
>
The data shows up in the table automagically.
>
>
The problems appear when I try to repeat the process with another file...
>
Application crashes via a seg violation.
>
>
I enter the routine and delete the columns from the table view using many
>
variations of code similar to:
>
// Try to determine if we have been here before if so then clean up...
>
colArray =[NSArray arrayWithArray: [tableView tableColumns]];
>
NSLog(@"tmp array %@",colArray);
>
if([colArray count]) {
>
for(i=0; i< [tmpArray count] ; i++){
>
[tableView removeTableColumn: [tmpArray objectAtIndex:i]];
>
}
>
NSLog(@"Finished releasing columns");
>
// [colArray release];
>
// [tableView tile];
>
// NSLog(@"Released tmpArray");
>
>
}
>
>
I then get the file name from the user and build the data array.
>
I then add new columns
>
>
Of course the data array is used in the tableView delegate methods.
>
>
Taint clear to me what a suitable protocol might be for switching
>
the number
>
of columns and supplying an data source that reflects the new file.
>
>
Thanks for any insight...
>
>
--Jerry
>
_______________________________________________
>
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.
_______________________________________________
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.