I am randomly generating 6 numbers using
self.number1 = [[NSNumber alloc] initWithInt:((arc4random() %
(hightestNumber-lowestNumber+1)) + lowestNumber)];
I do that for all six numbers, but some of the numbers come out the same. What code can I use to make sure that not any two or more numbers are the same value. I was going to use an if statement to compare the number to all six numbers and then call the arc4random code again but there is a possibility of it coming out the same value of another number again and I would have to test it again after. I really am stumped on this one. Thank you for your help.
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).
Another option is to pick numbers from an existing list, removing each one you choose:
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.