Xcode 7 arc4random缺少?

前端之家收集整理的这篇文章主要介绍了Xcode 7 arc4random缺少?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
参见英文答案 > arc4random_uniform not available in Xcode 7.0 beta (7a176x) on OSX 10.10.4                                    1个
我在Xcode 7发布时更新了它,但直到现在我还没有机会使用它.在制作游戏时,我需要像这样使用arc4random:

let RandomPosNmber = arc4random() % 4

当我尝试手动添加它时,它继续给我错误.唯一的选择是:

arc4random_addrandom(UnsafeMutablePointer<UInt8>,Int32)

arc4random_buf(UnsafeMutablePointer<Void>,Int)

arc4random_stir()

Apple是永久删除arc4random还是暂时删除?我上面提供的代码可以替代什么?如果需要更多代码,那么我将提供它.

解决方法

不,arc4random它不会丢失.你的代码运行正常.确保为iOS项目添加导入UIKit或为OSX项目导入Cocoa.你应该使用arc4random_uniform.

let randomPositionNumber = arc4random_uniform(4)

删除Xcode首选项可能有助于使用终端:

defaults delete com.apple.dt.Xcode

猜你在找的Xcode相关文章