【发布时间】:2016-03-21 19:52:20
【问题描述】:
[cs193p] Swift 计算器:为什么它不让我声明一个属性?这是简单的代码...
我正在使用 swift 1.2
错误是: 从未使用过变量“数字”的初始化;考虑替换为“_”的赋值 或删除它
这是代码
(它不喜欢'let digit'...'var digit'得到同样的错误)
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var display: UILabel!
@IBAction func appendDigit(sender: UIButton) {
//initialization of immutable value digit...
let digit = sender.currentTitle//<-- doesnt like this!!!!!!
}
}
【问题讨论】:
-
该消息非常清楚问题是什么:您正在初始化常量“数字”并且从未使用它。所以使用它。
标签: swift calculator cs193p