LoginSignup
14

More than 5 years have passed since last update.

【エラー】Collection was mutated while being enumerated.

Posted at

意味

列挙子つかってアクセスしてる最中に配列の中身を変更すんじゃねぇよ、次のオブジェクトわかんなくなるやろぼけ

解決策

for (id *obj in [hogeArray reverseObjectEnumerator]) {

}

ってかんじにreverseObjectEnumeratorを使う。
arrayが逆順になるので中身を変更しても次のオブジェクトは変わんないのでだいじょうぶ

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14