开发者

reading an array

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

NSMutableSet *aSet = [NSMutableSet setWithCapacity开发者_JS百科: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?


You can do:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜