views:

62

answers:

1
+2  Q: 

reading an array

I create random numbers using the following code and store them in an array.

NSMutableSet *aSet = [NSMutableSet setWithCapacity:6];

while([aSet count]<=6){

    int Randnum = arc4random() % 12;

    [aSet addObject:[NSNumber numberWithInt:Randnum]];
} 

NSArray *arrayOfUniqueRandomNumbers = [aSet allObjects];

Now, I need to read the array to get the values one-by-one using a forloop like

for (int i = 0; i<6; i++);

Can anyone please help me to finish the code?

+3  A: 

You can do:

for (NSNumber *val in arrayOfUniqueRandomNumbers) {
    int i = [val intValue];
    ...
}
notnoop