Hello,
I have this code:
When I have variableFactors with 1 object that satisfies the second if statement, it gets removed before the shouldRun line.
At this point I check with breakpoints that j is 0, variableFactors says '0 objects', I set a breakpoint for after shouldRun is reassigned and it is still true!!! The while loops again and the code crashes because I'm accessing an empty array.
Please help...
Richard
I have this code:
Code:
if ([variableFactors count] >= 1) {
short j = 0;
bool shouldRun = true;
while (shouldRun) {
if ([(RBMVariableFactor *)[variableFactors objectAtIndex:j] exponent] == 0) {
//if factor is empty then remove
[variableFactors removeObjectAtIndex:j];
}else{
j++;
}
shouldRun = (j <= ([variableFactors count] - 1));
}
}
At this point I check with breakpoints that j is 0, variableFactors says '0 objects', I set a breakpoint for after shouldRun is reassigned and it is still true!!! The while loops again and the code crashes because I'm accessing an empty array.
Please help...
Richard