我遇到了一個問題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