What code can I use to make sure that not any two or more numbers are the same value.
A set doesn't have duplicate values, so one option is to add numbers to a set until the size of the set reaches the number of objects you want (6, in your case).
NSMutableSet *set = [NSMutableSet set];
while ([set count] < 6) {
[set addObject:@((arc4random() % (hightestNumber-lowestNumber+1)) + lowestNumber)];
}
Another option is to pick numbers from an existing list, removing each one you choose:
NSArray *list = @[@5, @6, @7, @8, @9, @10, @11, @12, @13];
NSMutableArray *sourceList = [list mutableCopy];
NSMutableArray *finalList = [NSMutableArray array];
for (int i = 0; i < 6; i++) {
// (omitting code to choose a random index for brevity)
[finalList addObject:[sourceList objectAtIndex:randomIndex]];
[sourceList removeObjectAtIndex:randomIndex];
}
This method can work well if the list you're choosing from contains consecutive (or at least monotonically increasing) numbers, since that makes it easy to guarantee that the values in the source list are unique.