gpt4 book ai didi

swift - 获取变量的 bool 类型错误

转载 作者:行者123 更新时间:2023-11-30 14:06:47 25 4
gpt4 key购买 nike

我试图创建一个字符串变量 if 语句,但我得到 '()' 无法转换为 '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"

关于swift - 获取变量的 bool 类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32293171/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com