在变量上获取布尔类型错误

时间:2015-08-30 04:31:34

标签: swift optional

我试图制作一个字符串变量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.
    }

}

1 个答案:

答案 0 :(得分:0)

混淆分配运算符=等于运算符==

您需要等于运算符

if git == "4"