<__NSArrayM: 0xb550c30>was mutated while being enumerated

Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0xb550c30> was mutated while being enumerated.'

数组遍历事件,崩溃

for (MGFriendListModel *deletefriendModel in self.choosefriendListArray) {

if (deletefriendModel.id == model.id) {

MGLog(@"数组名字 %@",deletefriendModel.remarkName);

[self.choosefriendListArray removeObject:deletefriendModel];

}  }

解决办法:Block 枚举遍历解决

[self.choosefriendListArray enumerateObjectsUsingBlock:^(MGFriendListModel *deletefriendModel, NSUInteger idx, BOOL * _Nonnull stop) {

if (deletefriendModel.id == model.id) {

MGLog(@"数组名字 %@",deletefriendModel.remarkName);

[self.choosefriendListArray removeObject:deletefriendModel];

}

}];

你可能感兴趣的:(<__NSArrayM: 0xb550c30>was mutated while being enumerated)