2

I am in my playground. I was trying to use the arc4random_uniform func but I get this error: Use of unresolved identifier 'arc4random_uniform'

can I use another func instead?

vladasha
  • 403
  • 8
  • 15
  • possible duplicate of [How does one make random number between range for arc4random\_uniform()?](http://stackoverflow.com/questions/24132399/how-does-one-make-random-number-between-range-for-arc4random-uniform) – Guillaume Algis Jan 26 '15 at 16:06
  • No it is not a duplicate, His question is specifically for playground. I think that @Kirsteins answer is the good one. – LastMove Jan 26 '15 at 16:11

2 Answers2

10

Make sure you at least have imported import Foundation. Or platform specific import UIKit for iOS or import Cocoa for OSX.

Kirsteins
  • 27,065
  • 8
  • 76
  • 78
1

arc4random_uniform is apple platform only (from UIKit). If your playground is hosted on linux, it should not work.

Use rand() or Int/Double/Bool.Int.random()

https://stackoverflow.com/a/24007169/5717295

SLCH000
  • 1,821
  • 2
  • 14
  • 15