I have an NSArray
with 17 objects, something like this:
NSArray *objArray = [[NSArray alloc]initWithObjects: @"1",@"2",@"3",@"4",@"5",@"6"
,@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17", nil];
and an int
with a random number as follows:
int random = arc4random()%17+1;
I want to get a random object from this NSArray
without it being a duplicate, even if I closed the app (maybe by using NSUserDefaults
).
If I've gotten all the objects I want to generate a new random sequence for the same objects.
See Question&Answers more detail:os