本文介绍了在iOS中播种arc4random()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我的收集, arc4random()生成的随机数要比 rand()好得多,但是我还没有找到播种它的方法,因此我想就像使用 srand()一样。有办法吗?

From what I can gather arc4random() generates much better random numbers than rand() does, however I haven't seen a way to seed it, and I would like to just like using srand(). Is there a way?

推荐答案

这不是arc4random设计的目的。如文档所述:

That's not what arc4random is designed to do. As the documentation states:

由于它是从熵源重新播种的,因此您通过手动播种不会获得任何收益,实际上,这种方法不存在。

Since it is re-seeds itself from an entropy source anyway, you gain nothing by seeding it manually, and in fact, such a method does not exist.

这篇关于在iOS中播种arc4random()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 04:04