I am running the code like this and it is returning me this error:
Incompatible integer to pointer conversion initializing NSArray *_strong with an expression of type 'int'.
The code is like this:
- (NSArray *)randperm:(int)total
{
NSMutableArray *array = [[NSMutableArray alloc] init];
int counter = 0;
while (counter < total) {
NSNumber *randomInteger = [NSNumber numberWithInt:(arc4random_uniform(total)+1)];
if (![array containsObject:randomInteger]) {
[array addObject:(randomInteger)];
counter++;
}
}
NSArray *arr = [array copy];
return arr;
}
I am calling it this:
NSArray *array = randperm(6);
This line is returning me an error. Not sure why there is a such an error.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…