I’m facing a problem with NSMutableArray that give me a Exc_Bad_Access without a reason.
I have a UITableView that contain around 700 records, i wanna to activate a filter process to it, i’m using the following method to filter the content of the UITableView:
- (void) filterTableContentWith:(int)_minValue andWith:(int)_maxValue {
[tableContent removeAllObjects];
tableContent = [[NSMutableArray alloc] initWithArray:originalTableContent copyItems:YES];
if (_minValue == 0 && _maxValue == 0) {
NSLog(@"This is mean that no filter is activate here");
} else {
for (int x = ([tableContent count] - 1); x >= 0; x--) {
if ([[[tableContent objectAtIndex:x] objectForKey:@"price"] intValue] < _minValue && [[[tableContent objectAtIndex:x] objectForKey:@"price"] intValue] > _maxValue) {
[tableContent removeObjectAtIndex:x];
}
}
}
NSLog(@"tableContent count = %@",[tableContent count]);
[self.tableView reloadData];
}
When i’m calling this method, it gives me Exc_Bad_Access on NSLog(@"tableContent count ...
I think that [tableContent removeAllObjects]; is releasing the array, but it’s unreasonable.
Any help will be appreciated.
countreturns anint, so change yourNSLogto:and you’ll be fine.