【发布时间】:2015-01-26 15:57:25
【问题描述】:
我在我的操场上。我试图使用arc4random_uniform func 但我收到此错误:使用未解析的标识符'arc4random_uniform'
我可以改用另一个函数吗?
【问题讨论】:
-
不,这不是重复的,他的问题是专门针对游乐场的。我认为@Kirsteins 的回答很好。
标签: swift xcode6 swift-playground
我在我的操场上。我试图使用arc4random_uniform func 但我收到此错误:使用未解析的标识符'arc4random_uniform'
我可以改用另一个函数吗?
【问题讨论】:
标签: swift xcode6 swift-playground
确保您至少已导入 import Foundation。或者针对 iOS 的平台特定 import UIKit 或针对 OSX 的 import Cocoa。
【讨论】:
arc4random_uniform 仅适用于苹果平台(来自 UIKit)。
如果您的 Playground 托管在 linux 上,它应该无法工作。
使用rand() 或Int/Double/Bool.Int.random()
【讨论】: