我试图制作一个字符串变量if if statement并且我得到'()'不能转换为' BooleanType' 这是代码
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var button: UIBarButtonItem!
@IBOutlet weak var textView: UITextField!
var git = StringLiteralType()
var num = Int()
func go() {
if git = "4" {
button.enabled = true
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
git = self.textView.text!
button.enabled = false
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
答案 0 :(得分:0)
混淆分配运算符=
与等于运算符==
。
您需要等于运算符
if git == "4"