iphone - crash while removing objects from NSMutableArray -


in iphone project (arc enabled) have nsmuatble array contains 5 managed objects (which retrieved core data ) , in scenario need remove objects nsmutablearray

i have used following methods remove objects crashing in both cases crash log -[__nsarrayi removeobject:]: unrecognized selector sent instance 0xa391640

if (surveys && [surveys count]>0)         {              [surveys removeallobjects];             surveys = [[nsmutablearray alloc]init];         } 

and tried

if (surveys && [surveys count]>0)         {             for(survey *obj_survey in surveys)             {                 [surveys removeobject:obj_survey];             }              surveys = [[nsmutablearray alloc]init];         } 

can 1 tell me how empty array,, suggestions appreciated, thanx in advance

the answer simple.

for first case.
check part have initialized array, , check if somewhere through code, if have assigned nsarray nsmutablearray object.

for second case.
cannot remove objects array while enumerating through it. result in crash saying array has mutated while enumerating


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -