To the original posters from last year: random() always returns the same set of numbers if you don't seed it. arc4random() is easier to use; it seeds itself on the first call. Just use arc4random()%10 to get a number from 0 to 9 inclusive.
mooman576: Do you have your numbers in some sort of NSarray? Then you can shuffle them by sorting the array, but using a sort function that returns random results. Like this:
Code:
NSArray *sortedArray;
sortedArray = [anArray sortedArrayUsingFunction:shuffleSort context:NULL];
The shuffleSort function would look like this:
Code:
//this function gets called by sortedArrayUsingFunction:
//when sorting the array
NSInteger shuffleSort(id num1, id num2, void *context){
int result = arc4random()%3; // pick a number 0,1,2
if (result==0)
return NSOrderedAscending;
if (result==1)
return NSOrderedDescending
return NSOrderedSame;
}