小编use*_*720的帖子

需要许多随机数

我正在尝试创建一个策划风格的游戏,以建立我的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)];
Run Code Online (Sandbox Code Playgroud)

任何帮助都会非常有用.

iphone xcode ipad ios

3
推荐指数
1
解决办法
1269
查看次数

标签 统计

ios ×1

ipad ×1

iphone ×1

xcode ×1