NSMutableArray removeAllObjects issue
-
25-10-2019 - |
문제
I am trying to remove all the objects from the NSMutableArray and I am reloading the UITableView. But it produces SIGABRT in cellForRowAtIndexPath. The code is given below.
if ([nsMutableArray count] != 0) {
[nsMutableArray removeAllObjects];
[tableView reloadData];
}
It shows SIGABRT in
if (cell == nil) {
cell = (UICustomCell *)[nsMutableArray objectAtIndex:indexPath.row];
}
Help me to come out of this problem.
해결책
change this
to
if ([NSMutableArrayObject count] != 0) {
[NSMutableArrayObject removeAllObjects];
[tableView reloadData];
}
if (cell == nil) {
cell = (UICustomCell *)[NSMutableArrayObject objectAtIndex:indexPath.row];
}
다른 팁
You are calling instance methods (count
, removeAllObjects
, reloadData
, objectAtIndex:
) on classes (NSMutableArray
, UITableView
) instead of object instances.
제휴하지 않습니다 StackOverflow