Xcode 我的tableview在滚动时崩溃
我不理解。。。我成功地填充了我的表视图,但是当我滚动它时,它会崩溃而没有消息 我使用Xcode 我的tableview在滚动时崩溃,xcode,class,global-variables,Xcode,Class,Global Variables,我不理解。。。我成功地填充了我的表视图,但是当我滚动它时,它会崩溃而没有消息 我使用NSMutablearray创建我的tabQuestion,然后将其添加到我的委托中:cellforrowatinexpath NSDictionary *question = [self.tabQuestion objectAtIndex:indexPath.row]; [cell setAccessoryType: UITableViewCellAccessoryDisclosureIndicator
NSMutablearray
创建我的tabQuestion
,然后将其添加到我的委托中:cellforrowatinexpath
NSDictionary *question = [self.tabQuestion objectAtIndex:indexPath.row];
[cell setAccessoryType: UITableViewCellAccessoryDisclosureIndicator];
cell.textLabel.text = [NSString stringWithFormat:@"%@", [question objectForKey:@"question"]];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", [question objectForKey:@"reponse"]];
if ([[question objectForKey:@"bOk"] isEqualToString:@"1"]) {
cell.imageView.image = [UIImage imageNamed:@"ok.png"];
}
else
{
cell.imageView.image = [UIImage imageNamed:@"ok.png"];
}
[question release];
return cell;
您不应该
释放通过NSArray
的objectAtIndex:
方法返回的对象。这种情况很少发生
尝试删除所有行中的第一行:[question release]代码>
然后检查您的self.tabQuestion
是否包含所需数量的对象。如果我只添加这些行,则会出现崩溃->NSLog(@“%@%i”,[tabQuestion description],indexPath.row);NSLog(@“%@,[[self.tabQuestion objectAtIndex:indexPath.row]说明];索引(15)超出边界(0)我找到了解决方案。事实上,系统会自动释放我的对象。我用保留法解决它。