close

iOS exception - Collection was mutated while being enumerated


some related discuss

issue sample1

Before you loop over the array, you can create a new array with the elements. So when the original looped array is mutated (either by you, or by its owner) the array you loop over stays intact.

issue sample2


The error occurs because you are adding new objects to termsArray within the for loop
  • Create a new empty array (e.g.newTermsArray)
  • In the first loop create and add these new items to newTermsArray
  • Then you will need a second loop to add the items from newTermsArray back into the original termsArray

@synchronized (yourobject)
   
{
   
//do something with your object
   
}


and for how to analyze Call Stack Symbols, you need to know iOS crash report 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 tttt 的頭像
    tttt

    觀察筆記

    tttt 發表在 痞客邦 留言(0) 人氣()