我在計算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