here is the code, where listArray is NSMutableArray
……
listArray = [[NSMutableArray alloc] initWithCapacity:100];
for ( int i = 0 ; i < 100 ; i ++ )
[listArray addObject:[NSNumber numberWithInt:i]];
….
for(int max=99; max >= 0 ; max --)
{
int rN = (arc4random() % max) + 0;
//Warning 1: initialization makes integer from pointer without a cast
int temp = [listArray objectAtIndex:rN];
[listArray insertObject:[listArray objectAtIndex:max] atIndex:rN];
//passing argument 1 of 'insertObject:atIndex:' makes pointer from integer without a cast
[listArray insertObject:temp atIndex:max];
}
You need to “unbox” the int value:
The array stores objects (here an
NSNumber), while you want a plainint.The same holds for insertion, that’s why you call
[NSNumber numberWithInt:...]while adding.Edit: The indices in the array range from 0 … (count-1), not sure if your
+1does what it should.