swift3.0 中带有 arc4random 的 IBOutlet

IBOutlet with arc4random in swift3.0

我有代码

class ViewController: UIViewController {

var detailText: String = "Chance of win is 50%"

@IBOutlet weak var winChance: UILabel!

func someMethod () -> Void {
    print("Method called!")
}

override func viewDidLoad() {
    super.viewDidLoad()
self.winChance.text = self.detailText
}    }

我如何为这 50% 制作 arc4random? 如果我使用带有“(var)”的东西,那对我没有帮助 谢谢

试试这个

class ViewController: UIViewController {

    @IBOutlet weak var winChance: UILabel!

    func someMethod () -> Void {
        print("Method called!")
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        let randomNumber = Int(arc4random_uniform(100))
        self.winChance.text = "Chance of win is \(randomNumber)%"
    }    
}