3
我想创建一个主脑风格的游戏来建立我的iOS目标c技能。我试图使用以下内容创建0到9之间的6个随机数。在不同的时间运行时我会得到不同的数字,但每次运行时,所有6个数字总是相同的。需要许多随机数
NSNumber *n1 = [[NSNumber alloc]initWithInt:(random() % 10)];
NSNumber *n2 = [[NSNumber alloc]initWithInt:(random() % 10)];
NSNumber *n3 = [[NSNumber alloc]initWithInt:(random() % 10)];
NSNumber *n4 = [[NSNumber alloc]initWithInt:(random() % 10)];
NSNumber *n5 = [[NSNumber alloc]initWithInt:(random() % 10)];
NSNumber *n6 = [[NSNumber alloc]initWithInt:(random() % 10)];
任何帮助将是非常有用的。
[1](http://stackoverflow.com/questions/1436217/generating-random-values-in-iphone)[2](HTTP的可能重复://计算器。 com/questions/1449754/iphone-random-function-giving-me-the-same-random-number-everytime) – albertamg 2011-06-12 12:06:29