Presenting the Dice View

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import UIKit
 
class RollViewController: UIViewController {
 
    func randomDiceValue() -> Int {
 
        let randomValue = 1 + arc4random() % 6
 
        return Int(randomDiceValue)
    }
 
    @IBAction func rollTheDice(){
         
    }
}
1
2
3
4
5
6
7
8
9
10
@IBAction func rollTheDice(){
 
    let controller: DiceViewController
    controller = storyboard?.instantiateViewController(withIdentifier: "DiceViewController") as! DiceViewController
 
    controller.firstValue = randomDiceValue()
    controller.secondValue = randomDiceValue()
 
    present(controller, animated: true, completion: nil)
}