NSTableView don't display data
- by Tomas Svoboda
HI,
I have data in NSMutableArray and I want to display it in NSTableView, but only the number of cols has changed.
This use of NSTableView is based on tutorial: http://www.youtube.com/watch?v=5teN5pMf-rs
FinalImageBrowser is IBOutlet to NSTableView
@implementation AppController
NSMutableArray *listData;
- (void)awakeFromNib {
[FinalImageBrowser setDataSource:self];
}
- (IBAction)StartReconstruction:(id)sender
{
NSMutableArray *ArrayOfFinals = [[NSMutableArray alloc] init]; //Array of list with final images
NSString *FinalPicture;
NSString *PicNum;
int FromLine = [TextFieldFrom intValue]; //read number of start line
int ToLine = [TextFieldTo intValue]; //read number of finish line
int RecLine;
for (RecLine = FromLine; RecLine < ToLine; RecLine++) //reconstruct from line to line
{
Start(RecLine); //start reconstruction
//Create path of final image
FinalPicture = @"FIN/final";
PicNum = [NSString stringWithFormat: @"%d", RecLine];
FinalPicture = [FinalPicture stringByAppendingString:PicNum];
FinalPicture = [FinalPicture stringByAppendingString:@".bmp"];
[ArrayOfFinals addObject:FinalPicture]; // add path to array
}
listData = [[NSMutableArray alloc] init];
[listData autorelease];
[listData addObjectsFromArray:ArrayOfFinals];
[FinalImageBrowser reloadData];
NSBeep(); //make some noise
NSImage *fin = [[NSImage alloc] initWithContentsOfFile:FinalPicture];
[FinalImage setImage:fin];
}
- (int)numberOfRowsInTableView:(NSTableView *)tv {
return [listData count];
}
- (id)tableView:(NSTableView *)tv objectValueFromTableColumn:(NSTableColumn *)tableColumn row:(int)row {
return (NSString *)[listData objectAtIndex:row];
}
@end
when the StartReconstruction end the number of cols have changed right, but they're empty. When I debug app, items in listData is rigth.
Thanks