无法将Int的变量分配给UILabel

时间:2016-08-01 21:20:00

标签: ios swift

我无法将Int的变量分配给UILabel,我该如何解决这个问题呢?

导入UIKit

类ViewController:UIViewController {

@IBOutlet var CoinCounterInt: UILabel!
@IBOutlet weak var CoinCounter: UILabel!
var coins = 0
override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


@IBAction func Clicker(sender: AnyObject) {
    coins += 1
    CoinCounterInt = "\(coins)"
}

}

1 个答案:

答案 0 :(得分:1)

您需要将字符串分配给标签的text属性:
CoinCounterInt.text = "\(coins)"