I get an error message when I try to sort an array of one hundred thousand ints(I've tested the sort and it works for fifty thousand):
warning: could not load any Objective-C class information. This will significantly reduce the quality of type information available.
I also have the compare method iteratively and the same error appears
Why is this error message happening?
Is it possible to sort that list and if so how to fix it?
-(void) quickSort{
return [self quickSort:0 pivot:[self.toSort count]-1 right: [self.toSort count]-1];
}
-(void) quickSort:(int) left pivot:(int) pivot right:(int) right {
if(left < right){
pivot = [self compareToPivot:[[self.toSort objectAtIndex:right] intValue] start:left finish:right position:left];
[self quickSort:pivot+1 pivot:pivot right:right];
[self quickSort:left pivot:pivot right:pivot-1];
}
}
-(int) compareToPivot:(int) pivot start:(int)start finish:(int)finish position:(int)pos{
if(pos == finish){
[self switchNums:start second:finish];
return start;
}
if([[self.toSort objectAtIndex:pos] intValue] <= pivot){
[self switchNums:pos second:start];
return [self compareToPivot:pivot start:start+1 finish:finish position:pos+1];
}
return [self compareToPivot:pivot start:start finish:finish position:pos+1];
}
-(void) switchNums:(int)first second:(int)second{
id temp = [self.toSort objectAtIndex:second];
[self.toSort replaceObjectAtIndex:second withObject:[self.toSort objectAtIndex:first]];
[self.toSort replaceObjectAtIndex:first withObject:temp];
}
Iterative Compare and this runs fine:
-(int) compareToPivot:(int) pivot start:(int)start finish:(int)finish position:(int)pos{
while(pos != finish){
if([[self.toSort objectAtIndex:pos] intValue] <= pivot){
[self switchNums:pos second:start];
start+=1;
}
pos++;
}
[self switchNums:start second:finish];
return start;
}