reason: '*** Collection <__NSCFArray: 0x7ffa43528f70> was mutated while being enumerated.'
一,错误分析
1.崩溃代码如下:
//遍历当前数组,判断是否有相同的元素
for (NSString *str in self.searchHistoryArrM) {
if ([str isEqualToString:historyStr]) {
NSLog(@"%@====>%@",self.searchHistoryArrM ,str);
[self.searchHistoryArrM removeObject:str];
}
NSLog(@"%@",self.searchHistoryArrM);
}
2.打印出数组的内容以后,才发现是数组的内容有问题.移除元素后需要 break.