我在计算nsmutablearray中的对象数时遇到了问题。我有这样的代码:查找NSMutableArray中的对象数
- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath
{
NSUInteger numObjects = [selected count];// selected is nsmutablearray
for (int i = 0; i<numObjects; i++)
{
NSLog(@"%@ == %@ , nr.object =%@",[AnotherArray objectAtIndex:indexPath.row], [selektuara objectAtIndex:i], numObjects); // here stops the by reporting this: Program recived signal: "EXC_BAD_ACCESS"
if ([selected objectAtIndex:i] == [AnotherArray objectAtIndex:indexPath.row])
{
NSLog(@"%@",[selected objectAtIndex:i]);
return UITableViewCellAccessoryCheckmark;
}
else
{
return UITableViewCellAccessoryNone;
}
}
}
当我删除NSLog对象的数量,它只计算一个对象,只比较它。 那么有其他解决方案如何获得这个数字? 谢谢。
Thnx很多,现在我有这个数字,但我在循环返回时有另一个问题,即不让我比较其他对象,它只比较第一个对象,然后返回UITableViewCellAccessoryNone; – user751162
所以当你找到平等时不要返回 – Nekto