解決Collection <__NSArrayM: 0xb550c30> was mutated while being enumerated.

for (QHBossCurrencyListInfoModel *model in dataArray) {
        if ([model.currency isEqualToString:@"BTC"]) {
            [dataArray removeObject:model];
        }
}

致使會奔潰,由於改變了遍歷的數組數組

正確的寫法以下code

NSMutableArray *list = [NSMutableArray arrayWithArray:dataArray];
for (QHBossCurrencyListInfoModel *model in list) {
    if ([model.currency isEqualToString:@"BTC"]) {
            [dataArray removeObject:model];
    }
 }
相關文章
相關標籤/搜索