Easy TableView problem
Easy TableView problem
- Subject: Easy TableView problem
- From: "Barrett M. Conrad" <email@hidden>
- Date: Fri, 27 Feb 2004 11:04:38 -0600
Hi all,
Ok. I've fought with this for a day and a half and have come up
with nothing. I'm trying to implement a Table View for the first time.
Seems easy enough.
Here is the scenario. I have a data source class that contains an
array called "samples" of custom objects. The custom objects have an
attribute called "smplDate" that is returned by the method
"getSmplDate." My data source is initialized with two objects in its
"samples" array. The data source implements what I understand to be
the minimum two methods, "numberOfRowsInTableView" and
"tableView:objectValueForTableColumn:row", as follows:
-(int)numberOfRowsInTableView:(NSTableView *)tableView{
return [samples count];
}
-(id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row {
id theSample, tblObject;
if( [ [ tableColumn identifier ] intValue ] == 0) {
theSample = [samples objectAtIndex:row]; // I originally had
these as a single line, but split them for testing purposes. This is
the line that crashes.
tblObject = [theSample getSmplDate];
}
return tblObject;
}
I believe I have everything in Interface Builder setup correctly
because the above works to a point. When the program launches the
correct data is displayed in the Table View, but then it suddenly
crashes. It crashes the third time
"tableView:objectValueForTableColumn:row" is called. I'm assuming the
first two times it is called it display the data in the table
correctly, but the third time is a redraw (For what reason, I do not
know. I guess that's just what Cocoa does. I'm not doing it
purposefully.).
Here's the funny part. When I run the debugger, everything looks
kosher, then suddenly, on the third call of
"tableView:objectValueForTableColumn:row" the "samples" array in my
data source seems to "disappear." The debugger says the array has two
objects, which is right, then it spits out this: {(int)[$VAR count]}
objects, instead of "2 objects". Once it does this, the program
crashes.
I just can't seem to see the problem. I appreciate the help a great
deal.
Your Aspiring Mac Developer,
Barrett M. Conrad
email@hidden
_______________________________________________
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.