我也有类似的问题,在Snow Leopard上我的应用程序崩溃与崩溃报告说:
Dyld Error Message:
Symbol not found: _arc4random_buf
Referenced from: <myApp binary>
Expected in: /usr/lib/libSystem.B.dylib
我不得不多次阅读documentation,直到我意识到arc4random()
本身从10.4开始可用,但arc4random_buf()
仅在10.7以后才可用。如果你使用arc4random_buf()
函数(像我),它不会在10.6上运行。
所以,我刚刚更换了arc4random_buf()
功能与下面的C代码:
void myArc4RandBuf(uint8_t* randomBytes, size_t length) {
size_t intBufLength = (length/4)+1;
uint32_t randomInts[intBufLength];
for (int i = 0; i < intBufLength; i++) {
randomInts[i] = arc4random();
}
memcpy(randomBytes, randomInts, length);
}
这可能是有点慢,因为arc4random()
叫了好几次,但它工作在所有Mac OS从10.4至10.8 。
该手册页可以追溯到OS X v10.3。是什么让你认为'arc4random()'在10.6上不可用?你有错误信息吗? – 2011-11-07 23:58:49