2014-07-15 60 views
-1

这是我从github获得的代码,并且在我评论过的行上崩溃了,我知道EXC BAD ACCESS是当你不保留或释放某些东西但我有ARC启用的时候我不知道该怎么办。UITableView在github上滚动(国家列表)时崩溃

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
static NSString *cellIdentifier = @"Cell"; 

CountryCell *cell = (CountryCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 

if(cell == nil) { 
    cell = [[CountryCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier]; 
} 

cell.textLabel.text = [[_dataRows objectAtIndex:indexPath.row] valueForKey:kCountryName]; //here crashes 
cell.detailTextLabel.text = [[_dataRows objectAtIndex:indexPath.row] valueForKey:kCountryCallingCode]; //here crashes 

return cell; 

}

+0

是否GitHub的文件您已经下载有没有ARC支持? – GenieWanted

+0

不说什么,这是一个https://github.com/pradyumnad/Country-List/blob/master/README.md – Elgert

+0

你的意思是id?无所谓桌面被加载,但滚动 – Elgert

回答

3

我想设置文本属性标签中的一个最好的方式

cell.textLabel.text = [NSString stringWithFormat:@"%@",[[_dataRows objectAtIndex:indexPath.row] valueForKey:kCountryName]]; 

cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",[[_dataRows objectAtIndex:indexPath.row] valueForKey:kCountryCallingCode]]; 

它可能是有用的..

+0

我得到了这个问题,我的项目是针对iOS 4.3的,我不能升级它的原因很多,所以你知道如何将tableview代码更改为非ARC? – Elgert

+0

@Elgert为什么你想改变非弧..? xcode 4.3支持弧.. – ilesh

+0

整个项目是非弧,如果我转换为弧我得到100 +错误 – Elgert