【发布时间】:2010-07-07 06:24:00
【问题描述】:
这里是代码,其中 listArray 是 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];
}
【问题讨论】:
标签: objective-c iphone