I have been trying to fix this problem for hours. My app keeps crashing when I try to scroll. I looked in to the reusable section but am still stuck.
UPDATE: I am running xcode 4.2 with ARC & I am having bad access error.
UPDATE 2: I tried to locate the problem using Zombies but am still unable to fix the issue.
screenshot of zombies: http://img440.imageshack.us/img440/7651/instruments.png
UPDATE 3 [problem solved]: I made sure all outlets were [self set___:nil] in the ViewDidUnload. I also created a property for the added view instead of creating the view in the .m file.
THe comment at the bottom here helped me out too:
get "EXC_BAD_ACCESS" when trying dismissModalViewController after parent view controller has been viewDidUnload
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [self.sortedKeys count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [self.sortedKeys objectAtIndex:section];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
listData2 =[self.tableContents objectForKey:
[self.sortedKeys objectAtIndex:section]];
return [listData2 count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
questionTitle = [[self.tableContents objectForKey:[self.sortedKeys objectAtIndex: [indexPath section]]] objectAtIndex:[indexPath row]];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Foobar"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Foobar"];
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
cell.textLabel.textColor = [UIColor blueColor];
}
cell.textLabel.text = questionTitle;
return cell;
}
Rather than setting questionTitle in your cellForRowAtIndexPath which is (presumably) a property of your ViewController, define a local string:
and then use that to set the cell label:
Does that make any difference?