我遇到了一个问题NSMutableArray
给我一个Exc_Bad_Access
没有理由。NSMutableArray removeAllObjects问题
我有一个包含大约700个记录UITableView
,我想激活滤波处理它,我用以下方法给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];
}
当我调用这种方法,它给我Exc_Bad_Access
NSLog(@"tableContent count ...
我认为[tableContent removeAllObjects];
是释放数组,但它是不合理的。
任何帮助将不胜感激。
OMG,我多么愚蠢是我,我已经花费约8小时对此,非常感谢... – Scar