In my application, I want to compare floats in two NSMutableArrays - one sorted and the other unsorted - and get some action accordingly that comparison.
After each step, I want to remove the first group of floats in the unsorted array and go to next step.
However, always get a runtime error "index (0) beyond bounds (0)".
What is wrong ?
Thanks for help.
That is my code.
After each step, I want to remove the first group of floats in the unsorted array and go to next step.
However, always get a runtime error "index (0) beyond bounds (0)".
What is wrong ?
Thanks for help.
That is my code.
- (IBAction)calcid)sender {
calc = [[Calc alloc]init];
[calc setNum:[numField intValue]];
num = [calc get_num_value];
int vot_count = [votos count];
for(i = 0; i < vot_count; ++i)
for(j = 1; j < num + 1; ++j)
{
vot = [[votos objectAtIndex:i] intValue];
v = vot / j;
[ordem addObject:[NSNumber numberWithFloat:v]];
[quoc addObject:[NSNumber numberWithFloat:v]];
}
[ordem sortUsingSelectorselector(compare];
for (i = 0; i< (floor([ordem count]/2.0)); i++)
[ordem exchangeObjectAtIndex:i withObjectAtIndex[ordem count]-(i + 1))];
for(i = 0; i < vot_count; i++)
{
if([[quoc objectAtIndex:i] floatValue] < [[ordem objectAtIndex:num -1] floatValue])
man = 0;
for(j = 0; j < num; j++)
{
if([[quoc objectAtIndex:j] floatValue] >= [[ordem objectAtIndex:num -1] floatValue]) {
man = j + 1;
}
else
break;
}
[mand addObject:[NSNumber numberWithInt:man]];
[listBox_3 setDataSource:self];
[listBox_3 reloadData];
for(k = 0; k < num; k++)
[quoc removeObjectAtIndex:0];
}
}