2011-07-25 59 views
0

我想从NSMutableArray中删除所有对象,并重新加载UITableView。但它在cellForRowAtIndexPath中产生SIGABRT。代码如下。NSMutableArray removeAllObjects问题

if ([nsMutableArray count] != 0) { 

     [nsMutableArray removeAllObjects]; 
     [tableView reloadData]; 
    } 

它显示

if (cell == nil) { 

     cell = (UICustomCell *)[nsMutableArray objectAtIndex:indexPath.row]; 
    } 

帮助我走出这个问题的SIGABRT。

回答

0

改变这种

if ([NSMutableArrayObject count] != 0) { 
    [NSMutableArrayObject removeAllObjects]; 
    [tableView reloadData]; 
} 

if (cell == nil) { 
    cell = (UICustomCell *)[NSMutableArrayObject objectAtIndex:indexPath.row]; 
} 
+0

与原始代码有什么不同? – ttotto

0

要调用实例方法(count,​​,reloadDataobjectAtIndex:)上NSMutableArrayUITableView),而不是对象实例

+0

谢谢。那么,我该怎么做才能使它工作? – iOS

+0

使用你(希望)具有的变量。像'NSMutableArray * myArray; myArray = ...; if([myArray count]!= 0){...}' – DarkDust

+0

OMG !!!我只使用该对象。只是为了理解目的,我在这里使用了班级名称。我正在使用我的代码中提到的类的对象。 – iOS