What would cause this?
I have a grouped tableView that I've added in IB. 2 groups. 3 rows in each group.
It displays fine when my app is first run. (So I know I'm doing SOMETHING right. Wouldn't that mean that I (at least) have my Delegate, DataSource, IBOutlets, and connections set up correctly?)
But when I click on a button that calls [myTable reloadData]
it just crashes.
Initially, I thought it was due to my changes in the number of groups, number of rows, or changing the data in my dataSource (just a small NSMutableArray
).
But the same thing happens when I change NO data: Works fine the first time my tableView is displayed. But crashes when I call [myTable reloadData]
. (Whether the data has changed or not.)
I've stripped my code down to a barebones minimum... trying to find this bug.
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIndentifer = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndentifer]; if(cell == nil) cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIndentifer] autorelease]; cell.textLabel.text = @"Left Test"; cell.detailTextLabel.text = @"Right Test"; return cell; }
Here's the button-click code:
-(IBAction) reloadTable:(id)sender { if(myTable == nil) NSLog(@"myTable is nil"); else [myTable reloadData]; }
Here's the "error" (no help at all):
[Session started at 2010-02-19 10:04:14 -0100.] GNU gdb 6.3.50-20050815 (Apple version gdb-967) (Tue Jul 14 02:11:58 UTC 2009) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-apple-darwin".sharedlibrary apply-load-rules all Attaching to process 1081. kill kill quit The Debugger has exited with status 0.(gdb)
I've even tried hard-coding the "number of groups", "number of rows", "header text", "foot text", and "cell text". (In case my math was wrong calculating my objectAtIndex... or I had an array-dataSource that didn't have enough elements.)
Always the same problem: Displays fine the first time. Crashes when I try to reloadData.