UILabel.text未设置

时间:2017-05-28 17:04:51

标签: swift firebase-realtime-database

在我的代码中,我试图设置UILabel的文本。正在调用执行此操作的函数,并且除了UILabel.text赋值之外,其中的所有内容都按预期执行。以下是正在运行的代码的要点:

    override func viewDidAppear(animated: Bool) {
    var count2 = count

    ref.child(String(count2-3)).observeSingleEventOfType(.Value, withBlock: { (snapshot2) in
        var hitterRef = snapshot2.childSnapshotForPath("/Hitter")
        var pitcherRef = snapshot2.childSnapshotForPath("/Pitcher")
        var playRef = snapshot2.childSnapshotForPath("/Play")

        var play = String(playRef.childSnapshotForPath("/Name").value!)
        var outs = playRef.childSnapshotForPath("/Outs").value! as! Int
        var rbi = playRef.childSnapshotForPath("/RBI").value! as! Int

        assignScore(play, outs: outs, rbis: rbi, pitcherSelected: pitcherSelected, ResultsLabel: ResultsLabel, playName: playName, pointDiff: pointDiff)
    })
    print("successful delay")
    count2++
}

func assignScore(play:String, outs:Int, rbis:Int, pitcherSelected:Bool, ResultsLabel: UILabel, playName: UILabel, pointDiff: UILabel){
    var playScore = 0.0

    print("assign score is running")
    if(pitcherSelected == true) {

        /*
        *Below section covers the outs of the batter selected
        */
        //below means that the user has selected the batter
        if(outs == 0){
            if(play == "Walk") {
                //this means that the pitcher walked the batter
                playScore -= 0.5

            }else {
                //means just a regular out
                //nothing happens
            }
        }
    }
    ResultsLabel.text = "Test Text"
    print("Below text test")
}

0 个答案:

没有答案