8 Replies
      Latest reply on Apr 17, 2019 8:00 AM by OOPer
      Birkhoff92 Level 1 Level 1 (0 points)

        Hi, on my textbook I am using to learn Swift, report a method from the Swift library to generate random numbers. They are in the chapter where the protocols are explained. How come it gives me error on the arc4random method? Thank you

         

         

        EDIT:  sorry , I forgot to post the code, convinced I did: /

         

        // Sanseverino Raffaele
        // Random Generator
        
        protocol numeroRandom {
            func random()-> Double
        }
        
        class Generatore : numeroRandom {
            func random() -> Double {
                let n = Double(arc4random())
                return n
            }
        }
        let num = Generatore()
        num.random()