I am unsure why I get this error when I run my program a certain way.
2014-05-15 16:19:28.932 Puzzle[1002:f803] *** WebKit discarded an uncaught exception in the webView:shouldInsertText:replacingDOMRange:givenAction: delegate: <NSInternalInconsistencyException> -[__NSCFArray replaceObjectAtIndex:withObject:]: mutating method sent to immutable object
I have an NSMutableArray called 'levelsCompleteArray' that I am trying to cycle through to see when the first NO, (or 0) appears and to set that iteration to a variable called 'picIndex'. If there are no YES's in the array, then the program works fine. When there is one in the next iteration, however, I get the message posted above. Does anyone know why? Code below:
[levelsCompleteArray replaceObjectAtIndex:picIndex withObject:[NSNumber numberWithBool:YES]];
BOOL wonLevel=NO;
int i=picIndex;
while (wonLevel==NO)
{
BOOL status =[[levelsCompleteArray objectAtIndex:i] boolValue];
if (status==1)
{
i=i+1;
if(i==3)
{
picIndex=0;
wonLevel=YES;
}
}
else
{
picIndex=i;
wonLevel=YES;
}
}