在变量上获取布尔类型错误
Getting boolean type errors on variables
我正在尝试创建一个字符串变量 if 语句,但我得到 '()' is not convertible to '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.
}
}
混淆赋值运算符=
与等于运算符==
.
您需要等于运算符
if git == "4"
我正在尝试创建一个字符串变量 if 语句,但我得到 '()' is not convertible to '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.
}
}
混淆赋值运算符=
与等于运算符==
.
您需要等于运算符
if git == "4"